escaping strings
This commit is contained in:
parent
66bd99b524
commit
c501461b1e
@ -22,6 +22,7 @@ from ..objects import (
|
||||
)
|
||||
from ..tagging import write_metadata_to_target
|
||||
from ..utils.shared import DOWNLOAD_PATH, DOWNLOAD_FILE, DEFAULT_VALUES
|
||||
from ..utils.string_processing import fit_to_file_system
|
||||
|
||||
LOGGER = logging.getLogger("this shouldn't be used")
|
||||
|
||||
@ -36,7 +37,7 @@ class DefaultTarget:
|
||||
def __setattr__(self, __name: str, __value: str) -> None:
|
||||
if __name in DEFAULT_VALUES:
|
||||
if self.__getattribute__(__name) == DEFAULT_VALUES[__name]:
|
||||
super().__setattr__(__name, __value)
|
||||
super().__setattr__(__name, fit_to_file_system(__value))
|
||||
return
|
||||
|
||||
super().__setattr__(__name, __value)
|
||||
|
@ -6,4 +6,17 @@ def unify(string: str) -> str:
|
||||
"""
|
||||
|
||||
return string.lower()
|
||||
|
||||
def fit_to_file_system(string: str) -> str:
|
||||
string = string.strip()
|
||||
|
||||
while string[0] == ".":
|
||||
if len(string) == 0:
|
||||
return string
|
||||
|
||||
string = string[1:]
|
||||
|
||||
string = string.replace("/", "|").replace("\\", "|")
|
||||
|
||||
return string
|
||||
|
Loading…
Reference in New Issue
Block a user