Skip to content

Commit eb05de9

Browse files
committed
update to how the exclude setting behaves
1 parent 5e26333 commit eb05de9

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

core/settings.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,31 @@ def load(self) -> None:
4747
self._SETTINGS = json.load(f)
4848

4949
except FileNotFoundError as e:
50-
self._HANDLER(44, f"FATAL ERROR:\nSettings file could not be found!\n{e}")
50+
self._HANDLER(44, f"FATAL ERROR\nSettings file could not be found!\n{e}")
5151
sys.exit()
5252

5353
except PermissionError as e:
54-
self._HANDLER(43, f"FATAL ERROR:\nMissing permissions to read the settings file\n{e}")
54+
self._HANDLER(43, f"FATAL ERROR\nMissing permissions to read the settings file\n{e}")
5555
sys.exit()
5656

5757
except UnicodeError as e:
58-
self._HANDLER(42, f"FATAL ERROR:\nSystem failed to translate the Unicode characters in the settings file\n{e}")
58+
self._HANDLER(42, f"FATAL ERROR\nSystem failed to translate the Unicode characters in the settings file\n{e}")
5959
sys.exit()
6060

6161
except json.JSONDecodeError as e:
62-
self._HANDLER(1, f"FATAL ERROR:\nJSON file could not be parsed correctly.\n{e}")
62+
self._HANDLER(1, f"FATAL ERROR\nJSON file could not be parsed correctly.\n{e}")
6363
sys.exit()
6464

6565
except Exception as e:
66-
self._HANDLER(3, f"FATAL ERROR:\nUnknown error when attempting to parse the settings.\n{e}")
66+
self._HANDLER(3, f"FATAL ERROR\nUnknown error when attempting to parse the settings.\n{e}")
6767
sys.exit()
6868

6969
it_happened = False # [i] variable that indicates whether an expected key is... gone... (this sounds stupid)
7070

7171
for ek in ("theme", "databases", "imageRatio", "imageWidth", "widthIsHeight", "checkUpdates", "autoUpdateLevel", "excludeRule", "seasonalEasterEggs"):
7272
if ek not in self._SETTINGS:
7373
it_happened = True
74-
self._HANDLER(2, f"FATAL ERROR:\nMissing a key in the settings file.\nMissing key:\n'{ek}'")
74+
self._HANDLER(2, f"FATAL ERROR\nMissing a key in the settings file.\nMissing key:\n'{ek}'")
7575
continue
7676

7777
continue
@@ -106,23 +106,23 @@ def dump_settings(self, obj: dict, **kw) -> None:
106106
json.dump(obj, f, indent=kw.get("indent", 4))
107107

108108
except FileNotFoundError as e:
109-
self._HANDLER(44, f"FATAL ERROR:\nSettings file could not be found!\n{e}")
109+
self._HANDLER(44, f"FATAL ERROR\nSettings file could not be found!\n{e}")
110110
sys.exit()
111111

112112
except PermissionError as e:
113-
self._HANDLER(43, f"FATAL ERROR:\nMissing permissions to write to the settings file\n{e}")
113+
self._HANDLER(43, f"FATAL ERROR\nMissing permissions to write to the settings file\n{e}")
114114
sys.exit()
115115

116116
except UnicodeError as e:
117-
self._HANDLER(42, f"FATAL ERROR:\nSystem failed to translate the Unicode characters\n{e}")
117+
self._HANDLER(42, f"FATAL ERROR\nSystem failed to translate the Unicode characters\n{e}")
118118
sys.exit()
119119

120120
except json.JSONDecodeError as e:
121-
self._HANDLER(1, f"FATAL ERROR:\nJSON file could not be parsed correctly\n{e}")
121+
self._HANDLER(1, f"FATAL ERROR\nJSON file could not be parsed correctly\n{e}")
122122
sys.exit()
123123

124124
except Exception as e:
125-
self._HANDLER(3, f"FATAL ERROR:\nUnknown error when attempting to write to the settings\n{e}")
125+
self._HANDLER(3, f"FATAL ERROR\nUnknown error when attempting to write to the settings\n{e}")
126126
sys.exit()
127127

128128
@property
@@ -260,6 +260,9 @@ def exclude_rule_for_e3m1_e3m9(self, **kw) -> str | None:
260260
261261
:param obj: the object to save - if not specified, will save itself
262262
:param object: same as above but this one does not take priority
263+
264+
Returns:
265+
str: either 'warrens', 'hellkeep' or 'both' depending on what the user chose *(None if set to show none)*
263266
"""
264267

265268
__obj = kw.get('obj', None)
@@ -269,8 +272,8 @@ def exclude_rule_for_e3m1_e3m9(self, **kw) -> str | None:
269272

270273
a: str | None = self._SETTINGS['excludeRule']
271274

272-
if a in (None, 'null', 0, 'empty'):
273-
self._SETTINGS['excludeRule'] = 'none'
275+
if a not in ('warrens', 'hell_keep', 'both'):
276+
self._SETTINGS['excludeRule'] = None
274277

275278
if __obj is None:
276279
self.save_settings()
@@ -282,6 +285,9 @@ def exclude_rule_for_e3m1_e3m9(self, **kw) -> str | None:
282285

283286
@exclude_rule_for_e3m1_e3m9.setter
284287
def exclude_rule_for_e3m1_e3m9(self, value: str | None):
288+
if value not in ('warrens', 'hell_keep', 'both'):
289+
value = None
290+
285291
self._SETTINGS['excludeRule'] = value
286292

287293
def __getitem__(self, key: str) -> int | bool | str | list[str] | None:

0 commit comments

Comments
 (0)