1 # Parse lightcards config file
5 from pathlib import Path
9 class ConfigException(BaseException):
10 def __init__(self, message):
11 self.message = message
12 print(f"lightcards: {self.message}")
20 local_xdg = f"{os.path.expanduser('~')}/{os.environ.get('XDG_CACHE_HOME')}/lightcards/config.py"
21 local = f"{os.path.expanduser('~')}/.config/lightcards/config.py"
22 world = "/etc/lightcards/config.py"
23 world_default = "/usr/share/doc/lightcards/config.py"
25 f"{os.path.expanduser('~')}/.local/share/doc/lightcards/config.py"
28 if os.path.exists(world_default):
29 files.append(world_default)
30 if os.path.exists(local_default):
31 files.append(local_default)
32 if os.path.exists(world):
34 if os.path.exists(local_xdg):
35 files.append(local_xdg)
36 if os.path.exists(local):
38 if os.path.exists(file):
42 exec(Path(str(f)).read_text(), {}, config)