♻️ Refactoring of download.py ongoing.

This commit is contained in:
Robert Honz
2024-01-13 16:26:33 +01:00
parent dd8833add8
commit b59cba77c3
9 changed files with 248 additions and 143 deletions
-16
View File
@@ -1,16 +0,0 @@
def is_xml(value: str) -> bool:
result = False
if value and value.startswith("<?xml"):
result = True
return result
def is_json(value: str) -> bool:
result = False
if value and value.startswith("{"):
result = True
return result
+2 -2
View File
@@ -127,7 +127,7 @@ def path_file_sanitize(path_file: str, adapt: bool = False) -> (bool, str):
# Sanitize path
try:
pathname_sanitized = sanitize_filepath(pathname, replacement_text=" ", validate_after_sanitize=True)
pathname_sanitized = sanitize_filepath(pathname, replacement_text=" ", validate_after_sanitize=True, platform="auto")
except ValidationError:
# If adaption of path is allowed in case of an error set path to HOME.
if adapt:
@@ -137,7 +137,7 @@ def path_file_sanitize(path_file: str, adapt: bool = False) -> (bool, str):
# Sanitize filename
try:
filename_sanitized = sanitize_filename(path_file, replacement_text=" ", validate_after_sanitize=True)
filename_sanitized = sanitize_filename(filename, replacement_text=" ", validate_after_sanitize=True, platform="auto")
filename_sanitized_extension = Path(filename_sanitized).suffix
# Check if the file extension was removed by shortening the filename length