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}
# Validate data from schema file
schema = "test.stml"
valid = typeschemalib.schema_check(schema, data)
print(valid)
# Validate data from list of schema
schema = ["point: Int", "my_string: Str", "grade: Int"]
valid = typeschemalib.schema_check(schema, data)
print(valid)
# Validate data from dict of values
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.5.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for typeschemalib-1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce0924e0a11293f8e3ff61631911382ac98dc23d5443e9b1043f3859fe1177f2 |
|
MD5 | 7c8ea80cc27bec01181440b31c97c9dd |
|
BLAKE2b-256 | 0869d392de194a3655129da6da2159be3df1d5cc3114ceb87590b8ce5cac43b5 |