Provides tools for managing config files.
Project description
cfgtools
Provides tools for managing config files.
Installation
$ pip install cfgtools
Requirements
pyyaml
lazyr
Faker
htmlmaster
toml
Usage
Save to a config file
>>> import cfgtools as cfg
>>> f = cfg.config({"foo": "bar", "this": ["is", "an", "example"]})
>>> f.save("test.cfg", "yaml") # or: cfg.to_yaml("test.cfg")
If not specifeid, the format of the file will be automatically detected according to the file suffix. Valid formats include ini, json, yaml, pickle, toml, etc. For example:
>>> f.save("test.yaml") # a yaml file is created
>>> f.save("test.pkl") # a pickle file is created
>>> f.save("unspecified.cfg") # by default a json file is created
Read from a config file
>>> cfg.read("test.cfg")
cfgtools.config({'foo': 'bar', 'this': ['is', 'an', 'example']})
The encoding and format of the file will be automatically detected if not specified.
Modify configs
>>> f["foo"] = None
>>> f["that"] = {"is": ["also", "an", "example"]}
>>> f
cfgtools.config({
'foo': None, 'this': ['is', 'an', 'example'],
'that': {'is': ['also', 'an', 'example']},
})
See Also
Github repository
PyPI project
License
This project falls under the BSD 3-Clause License.
History
v0.0.5
- Added support for .toml files.
- New method for
ConfigIOWrapper:*.view_change(),*.asdict(),*.aslist().
v0.0.4
- Fixed a bug in path resolution.
v0.0.3
- Added reliance on
htmlmaster.
v0.0.2
- New method
ConfigIOWrapper.safematch().
v0.0.1
- Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cfgtools-0.0.5.tar.gz.
File metadata
- Download URL: cfgtools-0.0.5.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa6d11c56a5f93f50f527a2c6c9df711ed4f1c7f6aea2bc25a702753758033b1
|
|
| MD5 |
a2ca8d1490b614a268c39036335a5f77
|
|
| BLAKE2b-256 |
1df85caa6aa4b895e87518b628f2a1c74984342af4c96a7bdbaecbfb196ff055
|
File details
Details for the file cfgtools-0.0.5-py3-none-any.whl.
File metadata
- Download URL: cfgtools-0.0.5-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
947b51b6ad9de5660eb464a7d482ad4cd1c1b8d228c1f6f8fc62155147cfead1
|
|
| MD5 |
5a7b69d279ee0fdd2344eb54c6488df8
|
|
| BLAKE2b-256 |
9b3d350f6628b63180decc0ed6668a779d6fa6b8d56967d70f0eba64241382ff
|