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

Makes Config.read_config update instead of replace #4

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

dbosk
Copy link
Owner

@dbosk dbosk commented Jun 30, 2023

This makes Config.read_config update the config (Config.__data)
instead of replacing it with the contents of the file read.

A consequence of this is that one can have constructions such as

defaults = {
  "key1": "value",
  "key2": "value",
  "key3": "value"
}
conf = Config(json_data=defaults, conf_file="~/.config/app.config")
conf = Config(defaults)
conf.read_config("~/.config/app.config")

where the app.config file can override the values in defaults.

This makes `Config.read_config` update the config (`Config.__data`)
instead of replacing it with the contents of the file read.

A consequence of this is that one can have constructions such as
```python
defaults = {
  "key1": "value",
  "key2": "value",
  "key3": "value"
}
conf = Config(json_data=defaults, conf_file="~/.config/app.config")
conf = Config(defaults)
conf.read_config("~/.config/app.config")
```
where the `app.config` file can override the values in `defaults`.
@dbosk dbosk merged commit 8b3a2bd into main Jun 30, 2023
@dbosk dbosk deleted the update-config-on-read-not-replace branch June 30, 2023 11:43
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.

None yet

1 participant