From b664942d14890e3715d84edf47e3f709c2544c60 Mon Sep 17 00:00:00 2001 From: Demi <2e3s19@gmail.com> Date: Tue, 3 Sep 2019 15:00:38 -0400 Subject: [PATCH] Move default config to its file --- spytrack/config/config_storage.py | 33 +++---------------------------- spytrack/config/default_config.py | 27 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 30 deletions(-) create mode 100644 spytrack/config/default_config.py diff --git a/spytrack/config/config_storage.py b/spytrack/config/config_storage.py index 0fd7497..f334272 100644 --- a/spytrack/config/config_storage.py +++ b/spytrack/config/config_storage.py @@ -1,36 +1,9 @@ import yaml import argparse +import appdirs from pathlib import Path from config import Config, ConfigDict -import appdirs - -default_config = """ -daemon: - host: http://localhost - port: 9011 -gui: - interval: 5 - projects: - - name: coding - rules: - - app: pycharm - type: app - - title: Qt Designer - type: app - - type: web - url: .*qt.io.* - - type: web - url: python - - title: python - type: web - - title: pyqt - type: web - - app: code - title: .*Visual Studio Code - type: app - run_daemon: true - start_day_time: '5:00' -""" +from config.default_config import default_yaml def get_config_file() -> Path: @@ -57,7 +30,7 @@ def load(self) -> Config: try: if not self.file.exists(): self.file.parent.mkdir(parents=True, exist_ok=True) - values = yaml.safe_load(default_config) + values = yaml.safe_load(default_yaml) self._persist(values) else: values = yaml.safe_load(self.file.read_text()) diff --git a/spytrack/config/default_config.py b/spytrack/config/default_config.py new file mode 100644 index 0000000..f6d91c9 --- /dev/null +++ b/spytrack/config/default_config.py @@ -0,0 +1,27 @@ +default_yaml = """ +daemon: + host: http://localhost + port: 9011 +gui: + interval: 5 + projects: + - name: coding + rules: + - app: pycharm + type: app + - title: Qt Designer + type: app + - type: web + url: .*qt.io.* + - type: web + url: python + - title: python + type: web + - title: pyqt + type: web + - app: code + title: .*Visual Studio Code + type: app + run_daemon: true + start_day_time: '5:00' +"""