ConfigParser
A custom wrapper, written for python's own configparser, for reading and writing ini files, using simple dictionaries.
Can be installed using the setup.py file and by using the pip module
pip install dict-config-parser
Input arguments:
- config_file
As the name suggest, you can input the file name of the file, including the ini extension. You can also pass the path of the config file in this parameter.
- get_new_config
This is a boolean flag, when True, the code would ask for a new config and overwrite the previous one.
- default_keys
A dictionary needs to be passed to this input parameter. The keys of the dictionary would become the section names of the config file, while the array of values, against those keys, would become the section keys in that particular section. (See the test case for understanding)
A sample default keys might look this.
keys = {'DATASET_PATH' : ['VOC' , 'COCO'], 'MODEL_PATH' : ['WEIGHTS', 'JSON']}'
Usage:
You only have to pass through the input parameters and it would create a new file, if it doesn't already exist. This would create the required prompts on the command line and you can enter the values as needed.
config = ConfigParser(config_file='config.ini', get_new_config=True, default_keys=keys)
After creating the file, you would need to run the run_config method, from the current object of the class, to read the values from the created config file and return the values in a two-tiered dictionary.
config_dictionary = config.read_config()
The dictionary would have sections names, as its first tier keys and section key, as its second tier keys.
For example, if you passed the example default keys, you could get the value against 'JSON' key in the 'MODEL_PATH' section, by the command
required_value = config_dictionary['MODEL_PATH']['JSON']
Metadata
Release files for dict-config-parser 1.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 | |
|---|---|---|---|---|
| dict_config_parser-1.0.tar.gz | 3.3 kB | Without provenance | Details |
Release files / dict_config_parser-1.0.tar.gz
| Download URL | dict_config_parser-1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8db3376d6a75c2c14612a67138c64454b93e47b1df470658b217e686fe8ae15
|
|
BLAKE2b-256 checksum How to use checksums |
b5d3f39c79c9d31102efd96deb69c7a9e4a75b10beb4adc5ae77e8d134e2f519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9
|
Security for dict-config-parser 1.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.