2021-04-15 12:30:26 +03:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
@staticmethod
|
2021-04-15 14:21:36 +03:00
|
|
|
def load(path='config.yml'):
|
2021-04-15 12:30:26 +03:00
|
|
|
with open(path, 'rt', encoding='utf8') as f:
|
|
|
|
config = yaml.load(f.read(), Loader=yaml.FullLoader)
|
|
|
|
return Config(config)
|
|
|
|
|
|
|
|
def __init__(self, config):
|
|
|
|
dirs = config.get('dirs', {})
|
|
|
|
self.dir_tmp = Path(dirs.get('tmp', '/tmp/'))
|
2021-04-15 14:21:36 +03:00
|
|
|
self.dir_processed = Path(dirs.get('processed', './processed'))
|
2021-04-15 12:30:26 +03:00
|
|
|
self.dir_logs = Path(dirs.get('logs', './logs'))
|
|
|
|
self.dir_library = Path(dirs.get('library', './library'))
|
|
|
|
self.__setup_folders()
|
|
|
|
|
|
|
|
def __setup_folders(self):
|
|
|
|
self.dir_tmp.mkdir(exist_ok=True)
|
|
|
|
self.dir_logs.mkdir(exist_ok=True)
|
|
|
|
self.dir_library.mkdir(exist_ok=True)
|
|
|
|
|