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
from termcolor import colored
if __name__ == "__main__":
"""Test parse with stml file"""
schema_file = "test.stml"
data = {"point": 45, "my_string": "Hey", "grade": 4}
lines = typeschemalib.StmlReader(schema_file).lines
schema_dict = typeschemalib.StmlParser(lines).schema_dict
dataChecker = typeschemalib.DataChecker(schema_dict, data)
valid = dataChecker.check_type()
if valid is True:
print(colored(valid, 'green'))
else:
print(colored(valid, 'red'))
Todo
Make schema have regex Make schema have functions or options to validate data
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.2.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for typeschemalib-1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6286fb858709a5aad11d772c798f7e75c0721ee2965669728efce1f006325fba |
|
MD5 | 21d1556a63cb6b2f74cfbfea0c7765ae |
|
BLAKE2b-256 | 2f47c01cc7f8c9c3bf61b3cd4e61bc50b6458da9334952ad6414ca504ce4f3d3 |