Adds a local or global configuration file to OpenQML #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds a simple configuration file to OpenQML. Changes include:
Configuration
class inconfiguration.py
, to load, store, and save configuration information.__init__.py
, certain directories are now scanned, and if aconfig.toml
file is found, it is loaded up to be the default configuration. The three directories are:a. The current/script execution directory
b. The directory under environment variable
OPENQML_CONF
c. The standard user configuration directory (i.e.
~/.config/openqml
on linux,%APPDATA%\openqml
on windows, etc.)openqml.device
loader now also accepts aConfiguration
object as a keyword argument. If not provided, thedefault_config
determined in (2) is used. These are merged with the providedkwargs
and used to load the device.Two new modules are required:
toml
andappdirs
. TOML was chosen as it is simpler than JSON or YAML (it is based onini
), and standardised (supports comments, nesting, etc.). Theappdirs
module allows easy determination of standard user configuration directories across all operating systems.I've also added a
default_config.toml
file to the repository for reference. Since TOML allows nesting, you can set config options either (a) globally, (b) for all devices within a plugin, or (c) for only a specific device.Note: it should be up to the OpenQML documentation, as well as all plugin documentation, to clearly set out the configurations allowed in the config file.