Last updated:
0 purchases
AutoDict 2.0.0
AutoDict
Dictionary that automatically adds children dictionaries as necessary. Including a json based serialization and deserialization.
Environment
List of dependencies for package to run.
Required
None
Optional
None
Installation / Build / Deployment
Install module
> python -m pip install autodict
For development, install as a link to repository such that code changes are used.
> python -m pip install -e .
Usage
>>> from autodict import AutoDict, JSONAutoDict
>>>
>>> d = AutoDict()
>>> print(d)
{}
>>> d["level0"]["level1"]["level2"]["level3"] = "value"
>>> print(d)
{'level0': {'level1': {'level2': {'level3': 'value'}}}}
>>>
>>> with JSONAutoDict("autodict.json") as j:
... j["level0"]["level1"]["level2"]["level3"] = "value"
...
>>> print(open("autodict.json").read())
{
"__type__": "AutoDict",
"level0": {
"__type__": "AutoDict",
"level1": {
"__type__": "AutoDict",
"level2": {
"__type__": "AutoDict",
"level3": "value"
}
}
}
}
>>> with JSONAutoDict("autodict.json") as j:
... j["level0"]["key"] = "another value"
...
>>> print(open("autodict.json").read())
{
"__type__": "AutoDict",
"level0": {
"__type__": "AutoDict",
"level1": {
"__type__": "AutoDict",
"level2": {
"__type__": "AutoDict",
"level3": "value"
}
},
"key": "another value"
}
}
Running Tests
To run the automated tests, execute unittest discover:
> python -m unittest discover tests -v
To run the automated tests with coverage, execute coverage run:
> python -m coverage run
> python -m coverage report
Development
Code development of this project adheres to Google Python Guide
Styling
Use yapf to format files, based on Google's guide with the exception of indents being 2 spaces.
Versioning
Versioning of this projects adheres to Semantic Versioning and is implemented using git tags.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.