51 lines
1.1 KiB
Python
51 lines
1.1 KiB
Python
import os
|
|
import sys
|
|
from unicodedata import normalize
|
|
|
|
REPLACEMENTS = [
|
|
("_", " "),
|
|
("?", ""),
|
|
("!", ""),
|
|
(".", ""),
|
|
("-", " "),
|
|
(",", ""),
|
|
]
|
|
|
|
name_new = ""
|
|
i = 1
|
|
|
|
def compare(s1: str, s2: str) -> bool:
|
|
return normalize("NFKC", s1).casefold() == normalize("NFKC", s2).casefold()
|
|
|
|
|
|
|
|
|
|
file = open(sys.argv[1])
|
|
for line in file:
|
|
line = line[:-1]
|
|
for old, new in REPLACEMENTS:
|
|
line = line.replace(old, new)
|
|
name_new = line
|
|
#if "sed" in name_new:
|
|
# print("new: ", name_new)
|
|
for name in os.listdir(sys.argv[2]):
|
|
name = ((name.split(".")[0]).lower())
|
|
name = name.replace("_", " ")
|
|
# if "sed" in name:
|
|
# print ("pin 1 ",name)
|
|
name = name.replace("-", " ")
|
|
#if "sed" in name:
|
|
# print ("pin 2 ",name)
|
|
if compare(name, name_new):
|
|
print(i, ": ", line)
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
#print ("File name: ", name.split(".")[0], "---> Aus Datei: ", line)
|
|
#
|
|
#
|
|
#else:
|
|
# print(line[:-1], " ist nicht vorhanden")
|