Utils-Config
Library to use .json files as configuration objects using namedtuple.
This library let’s you use .json files as “objects” within your code.
Installation
pip install git+https://github.com/yeyeto2788/Utils-Config
Usage
Create a file called config.json (you can change the name to something you like) and add some content to it.
In this demo we add the following data.
{
"temperature": 30,
"screen": {
"width": 640,
"height": 480
},
"name": null,
"id": "4V3RYCR4ZY1D"
}
Now let’s head over Python and test the module and its functions.
Importing the module and loading our .json file.
import utils_config
config_file="./config.json"
config = utils_config.load_config(config_file)
Now let’s see what we’ve got in the config variable, serializing it into a dictionary.
utils_config.serialize_config(config)
Let’s access to its keys/attributes.
config.temperature
config.screen.width
config.name
config.id
Edit the current configuration (Take into account that this function will return a new configuration namedtuple)
config = utils_config.edit_config(config, {"id": "another_id"})
config.id
Save the configuration to a file.
utils_config.save_config(config_file, config)
Contributing
All contributions, pull requests and comments are welcome!
When contributing it is important to test the module in order to make sure everything is working as expected. For that install dependencies to run the tests.
pip install pytest pytest-cov mock pylint
Running tests and see coverage.
py.test --cov -v --cov-config=.coveragerc --cov-report=html
This will generate a report with the coverage which is at 100% now, let’s try to keep it at the same percentage.
Metadata
Release files for Utils-Config 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Utils-Config-1.0.0.tar.gz | 10.9 kB | Without provenance | Details for Utils-Config-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Utils_Config-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for Utils_Config-1.0.0-py3-none-any.whl |
Total release size: 16.1 kB
Release files / Utils-Config-1.0.0.tar.gz
| Download URL | Utils-Config-1.0.0.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ab3f2caae0d3ad2f2cf2e261c1117be0bec3f1d7a2e924f85ee024f74e6e995b
|
|
BLAKE2b-256 checksum How to use checksums |
60ae57eb29a546c7c0a1b612404e296f9321cd0e81f8c28f2f9315daa46c50a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9
|
Release files / Utils_Config-1.0.0-py3-none-any.whl
| Download URL | Utils_Config-1.0.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49c8573018ba387d40f45df42d0a8fabfccd59aecda86f74ba46662fdb60dcce
|
|
BLAKE2b-256 checksum How to use checksums |
0865a2597196c00724c3db81a24e326d74560196b55d5b797c5bc0ff72609aa6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9
|
Security for Utils-Config 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.