Skip to main content

Ensure nested dictionary structure.

Project description

PyChecKey

Ever have JSON or a large dictionary that you want to validate before you jump deeper into it? PyChecKey allows you to check a dictionary-like object against a defined structure.

This works with Python 3.5+.

Components

Below are the components and common examples of how to use them.

KeyEnsurer

A KeyEnsurer allows checking against a dictionary-like structure.

from pycheckey import KeyEnsurer


data = {
    "key1": 4,
    "key2": {
        "innerKey": "hi"
    }
}

ensurer = KeyEnsurer(data=data, required_keys=['key1', 'key2.innerKey', 'key3'])

ensurer.validate()  # Will return false because key3 does not exist!
print(ensurer.missing)  # ['key3']

ensurer.key_exists(data, 'key2.inner')  # Returns true because data[key2][inner] exists

Local Development

To work on this repository, you need virtualenv. Clone it first, then run the following two commands.

$ virtualenv -p python3 venv
$ source venv/bin/activate

Running Tests

Run pytest from the root directory to run all tests.

Linting

Run pylint from the root directory to lint the code files.

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

pycheckey-0.3.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

pycheckey-0.3-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file pycheckey-0.3.tar.gz.

File metadata

  • Download URL: pycheckey-0.3.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for pycheckey-0.3.tar.gz
Algorithm Hash digest
SHA256 93d1b8a4091c0596ee6d246b1814f7664d90f30a673cf5597651f96bef8d63ba
MD5 ad80583dad9603052bba6111899c64cc
BLAKE2b-256 f68447eb4f75d1047504cfe598b26ce79e1b16ac65a888edc13790b821879115

See more details on using hashes here.

File details

Details for the file pycheckey-0.3-py3-none-any.whl.

File metadata

  • Download URL: pycheckey-0.3-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for pycheckey-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 daf5182fcb7305100ec81e89fce2e04f96c7906e8b0b8a3d9d90f858270fce87
MD5 8218b204a4c60ee69fb275607f9973c8
BLAKE2b-256 93031a159be71a819d5c69e863a626298713b012564bde0ea95bbe2e533afda0

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