Skip to main content

Dictionary that automatically adds children dictionaries as necessary

Project description

AutoDict

Unit Test Pylint Coverage Latest Version

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

AutoDict-2.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

AutoDict-2.0.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file AutoDict-2.0.0.tar.gz.

File metadata

  • Download URL: AutoDict-2.0.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for AutoDict-2.0.0.tar.gz
Algorithm Hash digest
SHA256 94c37f5ffa3cbf2df08b19b90b17ec4a1ea0df7bc4f57e7eb5c0f133fab64190
MD5 4367063f487957e4fe08fa3d4945d334
BLAKE2b-256 50c6149919b202f0f05b16848dbb92bafa9e2a37dee51059c674370aec2f5131

See more details on using hashes here.

File details

Details for the file AutoDict-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: AutoDict-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for AutoDict-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96033dfa57baee7bf1ce4d39ad706623c59c98b51a9c7f14a7c59f18133c7ad2
MD5 1e44795f2d9c297db1d7b6b9c9f4ea52
BLAKE2b-256 6bf9455077054e9ff4027891e6a2a53d177c1d97b7745772342f5ed2c7d40e8b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page