summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Honz <exislow+github@gmail.com>2024-01-13 12:04:35 +0100
committerRobert Honz <exislow+github@gmail.com>2024-01-13 12:04:35 +0100
commitdd8833add888412ff192d9a61466c8c16c3939e2 (patch)
tree01115ca23e41ab02e0f36d0857cd83b5bef489e6
parent14483a162949dcdffc1fe36b5c4962f1926beaa3 (diff)
downloadtidal-dl-ng-dd8833add888412ff192d9a61466c8c16c3939e2.tar.gz
♻️ Refactored linter warnings.
-rw-r--r--tidal_dl_ng/download.py6
-rw-r--r--tidal_dl_ng/helper/format.py10
-rw-r--r--tidal_dl_ng/helper/path.py12
3 files changed, 13 insertions, 15 deletions
diff --git a/tidal_dl_ng/download.py b/tidal_dl_ng/download.py
index 350150b..70d8123 100644
--- a/tidal_dl_ng/download.py
+++ b/tidal_dl_ng/download.py
@@ -137,11 +137,7 @@ class Download:
# Compute if and how downloads need to be skipped.
if self.skip_existing:
- if self.skip_existing == SkipExisting.ExtensionIgnore:
- extension_ignore = True
- else:
- extension_ignore = False
-
+ extension_ignore = self.skip_existing == SkipExisting.ExtensionIgnore
# TODO: Check if extension is already in `path_file` or not.
download_skip = check_file_exists(path_file, extension_ignore=extension_ignore)
else:
diff --git a/tidal_dl_ng/helper/format.py b/tidal_dl_ng/helper/format.py
index ab62a69..f71b28d 100644
--- a/tidal_dl_ng/helper/format.py
+++ b/tidal_dl_ng/helper/format.py
@@ -1,9 +1,8 @@
def is_xml(value: str) -> bool:
result = False
- if value:
- if value.startswith("<?xml"):
- result = True
+ if value and value.startswith("<?xml"):
+ result = True
return result
@@ -11,8 +10,7 @@ def is_xml(value: str) -> bool:
def is_json(value: str) -> bool:
result = False
- if value:
- if value.startswith("{"):
- result = True
+ if value and value.startswith("{"):
+ result = True
return result
diff --git a/tidal_dl_ng/helper/path.py b/tidal_dl_ng/helper/path.py
index a907985..5acfff4 100644
--- a/tidal_dl_ng/helper/path.py
+++ b/tidal_dl_ng/helper/path.py
@@ -128,12 +128,12 @@ 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)
- except ValidationError as e:
+ except ValidationError:
# If adaption of path is allowed in case of an error set path to HOME.
if adapt:
pathname_sanitized = Path.home()
else:
- raise e
+ raise
# Sanitize filename
try:
@@ -146,7 +146,10 @@ def path_file_sanitize(path_file: str, adapt: bool = False) -> (bool, str):
file_extension = "_" + Path(path_file).suffix
filename_sanitized = filename_sanitized[: -len(file_extension)] + file_extension
except ValidationError as e:
- raise e
+ # TODO: Implement proper exception handling and logging.
+ print(e)
+
+ raise
# Join path and filename
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:
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