A yaml like schema that can be used to check dictionaries for correct schema
Project description
lib_type_schema
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
import file_reader
# Set schema file
schema_file = "test.stml"
# Set Data dictionary that corresponds to schema file
data = {"point": 45, "my_string": "Hey", "grade": 4.5}
# Check data for correct schema_file
dataChecker = file_reader.DataChecker(schema_file, data)
# Run type check to see if data corresponds
# valid will be True if schema is correct, it will throw errors otherwise
valid = dataChecker.check_type()
Todo
- Should incorrect schema throw error or just return false?
- Should there be an option for both?
- Have types for id and for more complex types that can be stored in mongodb documents
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-0.3.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for typeschemalib-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64b8a5327416b17e55bf8208a9275f0d475f34bbbefc5662ffb6b04d5034c567 |
|
MD5 | cb93f7bd37ece139cbb15cb09915af66 |
|
BLAKE2b-256 | 95323772713c2b6a463a8c563a8cf99bc774caac13c073d845e69e35d41853a7 |