translit
This commit is contained in:
parent
a56ccc463d
commit
385edc7087
@ -14,3 +14,4 @@ tqdm~=4.65.0
|
||||
peewee~=3.15.4
|
||||
ffmpeg-python~=0.2.0
|
||||
platformdirs~=3.2.0
|
||||
transliterate~=1.10.2
|
@ -1,12 +1,22 @@
|
||||
from transliterate.exceptions import LanguageDetectionError
|
||||
from transliterate import translit
|
||||
|
||||
|
||||
def unify(string: str) -> str:
|
||||
"""
|
||||
returns an unified str, to make comparosons easy.
|
||||
an unified string has following attributes:
|
||||
returns a unified str, to make comparisons easy.
|
||||
a unified string has the following attributes:
|
||||
- is lowercase
|
||||
"""
|
||||
|
||||
try:
|
||||
string = translit(string, reversed=True)
|
||||
except LanguageDetectionError:
|
||||
pass
|
||||
|
||||
return string.lower()
|
||||
|
||||
|
||||
def fit_to_file_system(string: str) -> str:
|
||||
string = string.strip()
|
||||
|
||||
@ -19,4 +29,3 @@ def fit_to_file_system(string: str) -> str:
|
||||
string = string.replace("/", "|").replace("\\", "|")
|
||||
|
||||
return string
|
||||
|
Loading…
Reference in New Issue
Block a user