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.

Files for pycheckey, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size pycheckey-0.3-py3-none-any.whl (2.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pycheckey-0.3.tar.gz (2.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page