chuwi-minibook-tablet-mode/tabletmode/config.py

24 lines
485 B
Python
Raw Normal View History

2020-03-26 11:47:41 +01:00
"""Configuration file parsing."""
from json import load
from logging import getLogger
from pathlib import Path
2021-01-05 11:36:46 +01:00
__all__ = ['load_config']
2020-03-26 11:47:41 +01:00
CONFIG_FILE = Path('/etc/tablet-mode.json')
LOGGER = getLogger('tabletmode')
2021-01-05 11:36:46 +01:00
def load_config() -> dict:
2020-03-26 11:47:41 +01:00
"""Returns the configuration."""
try:
with CONFIG_FILE.open('r') as cfg:
return load(cfg)
except FileNotFoundError:
LOGGER.warning('Config file %s does not exist.', CONFIG_FILE)
return {}