From 9c97fe66c63905b9d26f0bdbe71826e28ea6a36b Mon Sep 17 00:00:00 2001 From: qx6ghqkz <93668667+qx6ghqkz@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:24:31 +0000 Subject: [PATCH] refactor: minor corrections --- gallery-dl-server.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gallery-dl-server.py b/gallery-dl-server.py index 3a159ab..2843e14 100644 --- a/gallery-dl-server.py +++ b/gallery-dl-server.py @@ -104,7 +104,7 @@ def config_remove(path, key=None, value=None): else: if entry.get(key): entries.append(entry) - else: + elif value: if entry == value: entries.append(entry) @@ -112,27 +112,28 @@ def config_remove(path, key=None, value=None): try: _list.remove(entry) except Exception as e: - logger.error("Exception: %s", str(e)) + logger.error("Exception: %s", e) else: removed_entries.append(entry) if isinstance(path, dict): _dict = path - if value: - for k, v in _dict.items(): - if k == key and v == value: - entries.append(k) - else: - for k in _dict.keys(): - if k == key: - entries.append(k) + if key: + if value: + for k, v in _dict.items(): + if k == key and v == value: + entries.append(k) + else: + for k in _dict.keys(): + if k == key: + entries.append(k) for entry in entries: try: val = _dict.pop(entry) except Exception as e: - logger.error("Exception: %s", str(e)) + logger.error("Exception: %s", e) else: removed_entries.append({entry: val})