Skip to content

Commit

Permalink
feat!: switched config format to toml (#75)
Browse files Browse the repository at this point in the history
* feat!: switched config format to toml
* build(deps): updated dependencies

BREAKING CHANGE: changes the config file used
  • Loading branch information
ErikBjare committed Jun 15, 2021
1 parent 2336a25 commit 4d6f4e7
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 47 deletions.
29 changes: 11 additions & 18 deletions aw_qt/config.py
@@ -1,20 +1,15 @@
from configparser import ConfigParser
from typing import List

from aw_core.config import load_config
import json
from aw_core.config import load_config_toml

# NOTE: Updating this won't update the defaults for users, this is an issue with how aw_core.config works
default_settings = {
"autostart_modules": json.dumps(
["aw-server", "aw-watcher-afk", "aw-watcher-window",]
),
}

default_config = ConfigParser()
default_config["aw-qt"] = default_settings
# Currently there's no reason to make them differ
default_config["aw-qt-testing"] = default_settings
default_config = """
[aw-qt]
autostart_modules = ["aw-server", "aw-watcher-afk", "aw-watcher-window"]
[aw-qt-testing]
autostart_modules = ["aw-server", "aw-watcher-afk", "aw-watcher-window"]
""".strip()


class AwQtSettings:
Expand All @@ -23,9 +18,7 @@ def __init__(self, testing: bool):
An instance of loaded settings, containing a list of modules to autostart.
Constructor takes a `testing` boolean as an argument
"""
qt_config = load_config("aw-qt", default_config)
config_section = qt_config["aw-qt" if not testing else "aw-qt-testing"]
config = load_config_toml("aw-qt", default_config)
config_section = config["aw-qt" if not testing else "aw-qt-testing"]

self.autostart_modules: List[str] = json.loads(
config_section["autostart_modules"]
)
self.autostart_modules: List[str] = config_section["autostart_modules"]
114 changes: 85 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4d6f4e7

Please sign in to comment.