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
Make documentation for stml writer
Add object type and class checker, isinstance issubclass time: DateTimeObject
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.6.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for typeschemalib-1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5d5f2464df68ce88771391b8e2bb1b1881b3e42896b5fe4d3ec649f071906a3 |
|
MD5 | e3fce741344e0c581cf56f0f118cfa58 |
|
BLAKE2b-256 | 218fdb7994a2f67fed921fb5d556c2232c447147852083f96fad5a223093c201 |