A yaml like schema that can be used to check dictionaries for correct schema
Project description
typeschemalib
A yaml like schema that can be used to check dictionaries for correct schema
Schema file
schema example
point: Int
my_string: Str
grade: Float
data example
{"point": 45, "my_string": "Hey", "grade": 4.5}
Checking data for correct schema
Test parse with stml file
from typeschemalib import typeschemalib
if __name__ == "__main__":
data = {"point": 45, "my_string": "Hey", "grade": 4.5}
schema = "test.stml"
valid = typeschemalib.schema_check(schema, data)
print(valid)
schema = ["point: Int", "my_string: Str", "grade: Int"]
valid = typeschemalib.schema_check(schema, data)
print(valid)
schema = {"point": "Int", "my_string": "Str", "grade": "Int"}
valid = typeschemalib.schema_check(schema, data)
print(valid)
Todo
Make schema have regex
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
typeschemalib-1.3.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for typeschemalib-1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 321c5af199b9a669de7f301b06e00f301343af36e7e32ad5b8c49285b77a0e2e |
|
MD5 | 32400e580d6ed848548040206284de32 |
|
BLAKE2b-256 | 6643abef80d8b525d55efd4cc7a902dab712cc6f7727b4264fb97979d6a4527b |