♻️ Refactored linter warnings.
This commit is contained in:
@@ -137,11 +137,7 @@ class Download:
|
|||||||
|
|
||||||
# Compute if and how downloads need to be skipped.
|
# Compute if and how downloads need to be skipped.
|
||||||
if self.skip_existing:
|
if self.skip_existing:
|
||||||
if self.skip_existing == SkipExisting.ExtensionIgnore:
|
extension_ignore = self.skip_existing == SkipExisting.ExtensionIgnore
|
||||||
extension_ignore = True
|
|
||||||
else:
|
|
||||||
extension_ignore = False
|
|
||||||
|
|
||||||
# TODO: Check if extension is already in `path_file` or not.
|
# TODO: Check if extension is already in `path_file` or not.
|
||||||
download_skip = check_file_exists(path_file, extension_ignore=extension_ignore)
|
download_skip = check_file_exists(path_file, extension_ignore=extension_ignore)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
def is_xml(value: str) -> bool:
|
def is_xml(value: str) -> bool:
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
if value:
|
if value and value.startswith("<?xml"):
|
||||||
if value.startswith("<?xml"):
|
result = True
|
||||||
result = True
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -11,8 +10,7 @@ def is_xml(value: str) -> bool:
|
|||||||
def is_json(value: str) -> bool:
|
def is_json(value: str) -> bool:
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
if value:
|
if value and value.startswith("{"):
|
||||||
if value.startswith("{"):
|
result = True
|
||||||
result = True
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -128,12 +128,12 @@ def path_file_sanitize(path_file: str, adapt: bool = False) -> (bool, str):
|
|||||||
# Sanitize path
|
# Sanitize path
|
||||||
try:
|
try:
|
||||||
pathname_sanitized = sanitize_filepath(pathname, replacement_text=" ", validate_after_sanitize=True)
|
pathname_sanitized = sanitize_filepath(pathname, replacement_text=" ", validate_after_sanitize=True)
|
||||||
except ValidationError as e:
|
except ValidationError:
|
||||||
# If adaption of path is allowed in case of an error set path to HOME.
|
# If adaption of path is allowed in case of an error set path to HOME.
|
||||||
if adapt:
|
if adapt:
|
||||||
pathname_sanitized = Path.home()
|
pathname_sanitized = Path.home()
|
||||||
else:
|
else:
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
# Sanitize filename
|
# Sanitize filename
|
||||||
try:
|
try:
|
||||||
@@ -146,7 +146,10 @@ def path_file_sanitize(path_file: str, adapt: bool = False) -> (bool, str):
|
|||||||
file_extension = "_" + Path(path_file).suffix
|
file_extension = "_" + Path(path_file).suffix
|
||||||
filename_sanitized = filename_sanitized[: -len(file_extension)] + file_extension
|
filename_sanitized = filename_sanitized[: -len(file_extension)] + file_extension
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
raise e
|
# TODO: Implement proper exception handling and logging.
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
raise
|
||||||
|
|
||||||
# Join path and filename
|
# Join path and filename
|
||||||
result = os.path.join(pathname_sanitized, filename_sanitized)
|
result = os.path.join(pathname_sanitized, filename_sanitized)
|
||||||
@@ -158,6 +161,7 @@ def check_file_exists(path_file: str, extension_ignore: bool = False):
|
|||||||
if extension_ignore:
|
if extension_ignore:
|
||||||
path_file = Path(path_file).stem + ".*"
|
path_file = Path(path_file).stem + ".*"
|
||||||
|
|
||||||
result = True if glob.glob(path_file) else False
|
# TODO: Check what happens is (no) files .
|
||||||
|
result = bool(glob.glob(path_file))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user