Schema Loader
Warning
This section is a work in progress
JSONSchemaLoader
Bases: SchemaLoader
A schema loader for JSON files.
This class extends the SchemaLoader to provide functionality for loading
schemas defined in JSON format. It registers itself with the identifier "json"
and uses the json.load method to parse JSON files.
Methods
init(): Initializes the loader and registers the JSON loading function. _load(schema: str) -> dict: Static method that loads and parses a JSON schema file. Parameters ---------- schema : str The file path to the JSON schema. Returns ------- dict The parsed schema as a Python dictionary.
Source code in datachecker/checks_loaders_and_exporters/schema_loader.py
SchemaLoader
SchemaLoader is a class for registering and loading schema parsing functions based on format. Class Attributes: format_dictionary (dict): A mapping from format names (str) to schema loader functions. Methods
init(self, format, schema_loader_function): Registers a schema loader function for a given format. load(cls, schema, format): Loads and parses a schema using the registered loader function for the specified format. Parameters ---------- schema : str The file path to the schema. format : str The format identifier (e.g., "json", "yaml"). Returns ------- dict The parsed schema as a Python dictionary. Raises ------ ValueError If the requested format is not registered in format_dictionary.
Source code in datachecker/checks_loaders_and_exporters/schema_loader.py
TOMLSchemaLoader
Bases: SchemaLoader
A schema loader for TOML files.
This class extends the SchemaLoader to provide functionality for loading
schemas defined in TOML format. It registers itself with the identifier "toml"
and uses the tomli.load method to parse TOML files.
Methods
init(): Initializes the loader and registers the TOML loading function. _load(schema: str) -> dict: Static method that loads and parses a TOML schema file. Parameters ---------- schema : str The file path to the TOML schema. Returns ------- dict The parsed schema as a Python dictionary.
Source code in datachecker/checks_loaders_and_exporters/schema_loader.py
YAMLSchemaLoader
Bases: SchemaLoader
A schema loader for YAML files.
This class extends the SchemaLoader to provide functionality for loading
schemas defined in YAML format. It registers itself with the identifier "yaml"
and uses the yaml.safe_load method to parse YAML files.
Methods
init(): Initializes the loader and registers the YAML loading function. _load(schema: str) -> dict: Static method that loads and parses a YAML schema file. Parameters ---------- schema : str The file path to the YAML schema. Returns ------- dict The parsed schema as a Python dictionary.