Install
pip install kwconfig
For the latest developer version, see Developer Install.
Usage
import kwconfig
# Specify a file path for creating kwconfig object
config = kwconfig.manage('config.json', defaults={'key0': 'value0'})
# Update the config file with a key and value dict
config.update({'key1': 'value1', 'key2': 'value2'})
# Add a keyword dict to existing config file
# If a key exists, it will be updated
# If a key does not exist, it will be added
other_config = {'key3': 'value3'}
other_config = config.add(other_config)
# Write new values using keyword dict
config.overwrite({
'new_key1': 'new_value1',
'new_key2': 'new_value2'
})
# Obtain a dict of the config file contents
kw = config.read()
# Remove the key named "key1"
config.remove('key1')
# Reset to defaults
config.reset()
# Parsing a keyword list into dict ----
# Create a sample list of keyword arguments
argv = ['--key1=value1', '--key2=value2']
# Parse into a keyword dict
kwdict = kwconfig.parse(argv)
# View the values of key1 and key2
print('key1: ' + kwdict['key1'])
print('key2: ' + kwdict['key2'])
For more usage details, see the Documentation.
Developer Notes
Developer Install
Install the latest developer version with pip from github:
pip install git+https://github.com/rrwen/kwconfig
Install from git cloned source:
Ensure git is installed
Clone into current path
Install via pip
git clone https://github.com/rrwen/kwconfig cd kwconfig pip install . -I
Tests
Clone into current path git clone https://github.com/rrwen/kwconfig
Enter into folder cd kwconfig
Ensure unittest is available
Run tests
pip install . -I python -m unittest
Documentation Maintenance
Ensure sphinx is installed pip install -U sphinx
Update the documentation in docs/
pip install . -I sphinx-build -b html docs/source docs
Upload to Github
Ensure git is installed
Add all files and commit changes
Push to github
git add . git commit -a -m "Generic update" git push
Upload to PyPi
Ensure twine is installed pip install twine
Ensure sphinx is installed pip install -U sphinx
Run tests and check for OK status
Delete dist directory
Update the version in kwconfig/__init__.py
Update the documentation in docs/
Create source distribution
Upload to PyPi
pip install . -I python -m unittest sphinx-build -b html docs/source docs python setup.py sdist twine upload dist/*
Metadata
Release files for kwconfig 1.1.7
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 |
|---|---|---|---|---|
| kwconfig-1.1.7.tar.gz | 4.8 kB | Without provenance | Details for kwconfig-1.1.7.tar.gz |
Release files / kwconfig-1.1.7.tar.gz
| Download URL | kwconfig-1.1.7.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
735b3cb21198f4bd2acaff7dcae97b3b0fcb765d73234a0afa635f94e9298e5f
|
|
BLAKE2b-256 checksum How to use checksums |
474987ca96c4c299d24700daf45f4bb8d900b05e15e8c48179b13008fc29c509
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for kwconfig 1.1.7
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.