Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

restricted dict

Project Description

Providing extracted dict (subclass of collections.UserDict).

how to use

(todo: description)

from kanagata import RestrictionBuilder

# group: name, users
# user: name, age, Option[skills], Option[school]
# skill: name
with RestrictionBuilder() as b:
    with b.define_dict("Group") as group:
        group.add_member("name", required=True)
        group.add_list("users", "User", required=True)

    with b.define_dict("User") as user:
        user.add_member("name", required=True)
        user.add_member("age", required=True)
        user.add_dict("school", "School", required=False)
        user.add_list("skills", "Skill", required=False)

    with b.define_dict("Skill") as skill:
        skill.add_member("name", required=True)

    with b.define_dict("School") as school:
        school.add_list("groups", "Group", required=True)
from models import User

# user can have only name, age, skills. (skills is optional)

user = User(name="foo", age=20, skills=[])
print(user)  # {'name': 'foo', 'age': 20, 'skills': []}

    user2 = User(name="bar")
    # ValueError: User: required fields {'age'} are not found
except ValueError:

    user["xxx"] = "bar"
    # ValueError: User: unsupported field 'xxx', field members=['name', 'age', 'school', 'skills']
except ValueError:

# user.skills can have only name.

user["skills"].append({"name": "math"})
print(user)  # {'skills': [{'name': 'math'}], 'age': 20, 'name': 'foo'}

    # ValueError: Skill: required fields {'name'} are not found
except ValueError:


  • default option support
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
kanagata-0.0.1-py2.py3-none-any.whl (6.9 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Oct 16, 2016
kanagata-0.0.1.tar.gz (4.3 kB) Copy SHA256 Checksum SHA256 Source Oct 16, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting