libtextworker 0.1.4
Cross-platform, free and open library for Python projects
|
Located in libtextworker.get_config
, GetConfig is a class which gives the user more power managing their configuration files - both JSON end INI format.
Firstly, install configparser
or commented-configparser
(saves infile comments) from Pypi.
Now make a new instance of GetConfig with your configs & file preloaded:
In the snippet above, cfgs
is a dictionary contains all your defaults for restore/compare(WIP?) purposes; target
is the path to the current settings file. Both 2 of them are passed into a new GetConfig instance (cfger
).
But since GetConfig derived from ConfigParser class (even you use Commented-configparser), you can add more to your liking (below are some of them, the most usefuls):
**<1>** this means you can do this in INI:
How about JSON support?
Well, just do the same as INI.
Now you can do anything you like.
GetConfig extends ConfigParser with these features:
These features makes GetConfig an unique thing you must see:)
A planned thing: GetConfig will use watchdog
module to dynamically notify the user when the file is changed outside, also an option to chose whetever to load the changes or not.
One more thing is the real restore (have I said this is available before?) previous user options. They should be available on 0.1.4 release.
Why "real"? Because the previous "restore" function (if it exists) not really something even "real" - you have to use move() function. Whatever... you still can.
GetConfig is the core of ColorManager, a class for GUIs in libtextworker.
To master everything you got from GetConfig, read all functions description and use they for your purpose.