24 lines
491 B
Python
24 lines
491 B
Python
|
"""Configuration file parsing."""
|
||
|
|
||
|
from json import load
|
||
|
from logging import getLogger
|
||
|
from pathlib import Path
|
||
|
|
||
|
|
||
|
__all__ = ['load_configuration']
|
||
|
|
||
|
|
||
|
CONFIG_FILE = Path('/etc/tablet-mode.json')
|
||
|
LOGGER = getLogger('tabletmode')
|
||
|
|
||
|
|
||
|
def load_configuration():
|
||
|
"""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 {}
|