Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor fofix.core.Config #118

Merged
merged 4 commits into from
Oct 18, 2020
Merged

Refactor fofix.core.Config #118

merged 4 commits into from
Oct 18, 2020

Conversation

alvanson
Copy link
Contributor

@alvanson alvanson commented Nov 2, 2017

Refactor and futurize fofix.core.Config as a small step toward #110.

Prototype is now a dict-like class, allowing multiple config prototypes to be created (e.g. separate prototypes for main config, themes, songs, etc). Note that the removed code (formerly) under # fix the defaults and non-existing keys is redundant as the prototype's default is looked up for every get() anyway.

The _ModuleWrapper hack at the end allows access to the default config through existing calls to Config.get() etc, but eliminates duplicate code and the need to keep function definitions in Config the class and Config the module synchronized. Ideally, Config the module should only be responsible for creating Config objects, and not for storing a default configuration file. Instead, the config files should be explicitly passed around as required.

Call to RawConfigParser._read() changed to ...readfp() as the latter is part of the public API and the former is an implementation detail that could (theoretically) change at any time.

@Linkid Linkid added cleanup and removed needs-work labels Oct 18, 2020
@Linkid Linkid added this to the 4.0 milestone Oct 18, 2020
@Linkid Linkid merged commit d6c57cb into fofix:master Oct 18, 2020
@Linkid
Copy link
Member

Linkid commented Oct 18, 2020

Thank you for this refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants