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

Config Update #841

Closed
wants to merge 19 commits into from
Closed

Config Update #841

wants to merge 19 commits into from

Conversation

das7pad
Copy link
Contributor

@das7pad das7pad commented Apr 18, 2017

The Config Class can now store defaults in background that do not need to be stored bulk in the users config.json.

.get_by_path, .get_option, .get_suboption and direct accessing will query defaults on KeyError/ValueErrors.

.set_by_path and .pop_by_path will still access the real config.json data.
With the arg fallback in .get_by_path and also in .exists, one can toggle the fallback to defaults.

Other changes:

  • the check for a change in the config is now on live data, .force_taint() is no more needed. f1a5ae5

  • create the path the user wants to store a value in, this can be toggled in .set_by_path with the argumentcreate_path.

  • use the configured default, in some cases just None was returned and overall the default was hardcoded to None, even though an argument on init existed. d2715fc

  • propper check for an existing path, None as value resulted in an non existing path

  • propper Exception handling, especially IOError killing the config bbb006a

  • (plugins can) validate their config parts with .validate 30eaa9e

  • use asyncio to schedule a delayed dump 81eacc3

das7pad added 19 commits April 17, 2017 23:36
there is no more need to manually toggle the changed state of the config

make .loads private

removed the return value from .save, it was False in every case

deprecate .force_taint(), keep it for backwards compatibility
ignore the state of the variable delay to cancel the delayed task in every case.
performing an undelayed dump might have lead to duplicate dumps.
no doing so might break dumping the config permanent
performace:
- do not check the the backup twice, ._loads will fail if it is also corrupt
- skip reading the config twice (on copy and on load)

do not use .format in logging
otherwise raise the exception

save the config after creating it
.set_by_path and .pop_by_path will not work on the defaults dict data

add a flag to .set_by_path to create the given path automatically
the recent version of .get_by_path returned None if the path did exist to position -1 in the keys_list. But this is not a valid check for a not existing path, as None is an allowed value for entrys in the config.
(or just stay below 81 char a line :D)
@das7pad das7pad mentioned this pull request Jul 17, 2017
@Terrance Terrance changed the base branch from v3.0 to staging December 7, 2018 20:22
@das7pad das7pad closed this Feb 2, 2022
@das7pad das7pad deleted the config-das7pad branch February 2, 2022 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant