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"
24 if os.path.exists(world):
26 if os.path.exists(local_xdg):
27 files.append(local_xdg)
28 if os.path.exists(local):
32 if not os.path.exists(file):
33 raise ConfigException(f'"{file}": No such file or directory') from None
36 exec(Path(str(f)).read_text(), {}, config)