omdata package

Submodules

omdata.design module

OpenMaker module for survey data schema.

This module contains functions and classes which can be used an editing interface to a predesigned JSON schema.

Todo:
  • Do the Sphinx documentation
  • Improve inplace editing methods.
exception omdata.design.OMSchemaKeyError(msg, code)[source]

Bases: Exception

OpenMaker data schema error for invalid key types.

Args:
msg (str): Human readable string describing the exception. code (int, optional): Error code.
Attributes:
msg (str): Human readable string describing the exception. code (int): Exception error code.
exception omdata.design.OMSchemaUnknown(msg, code)[source]

Bases: Exception

OpenMaker data schema error for unknown object types.

Args:
msg (str): Human readable string describing the exception. code (int, optional): Error code.
Attributes:
msg (str): Human readable string describing the exception. code (int): Exception error code.
class omdata.design.Schema(schema=None)[source]

Bases: object

A generic interface object for JSON Schemas of OpenMaker Project.

Attributes:
schema_file (string): A file path to a JSON schema file.
get_fields(schema=None, main_only=False)[source]
The method lists all of the fields of a given schema. It parses the entire
schema in JSON format.
Args:
schema (JSON): A JSON object which describes the schema (default None).
Returns:
(list of string): list of field names.
get_questionaire_matches()[source]
The method lists all of the fields of a given schema. It parses the entire
schema in JSON format.
Args:
schema (JSON): A JSON object which describes the schema (default None).
Returns:
(list of string): list of field names.
get_required_fields(schema=None)[source]
The method lists all the required fields of a given schema. It parses the entire
schema in JSON format.
Args:
schema (JSON): A JSON object which describes the schema (default None).
Returns:
(list of string): list of field names.
load(schema)[source]

The method loads a schema from a JSON object.

Args:
fname (dict): The JSON document in dictionary format.
Returns:
bool: True.
load_from_file(fname)[source]

The method loads a schema from a file path to a JSON schema file.

Args:
fname (str): The file path.
Returns:
bool: True if successful, False otherwise.
Raises:
FileNotFoundError: Raised if a given file is not accessable.
schema_file = None
omdata.design.get_field_names(schema)[source]

The method lists all of the fields of a given schema. It parses the entire schema in JSON format.

Args:
schema (JSON): A JSON object which describes the schema (default None).
Returns:
(list of string): list of field names.
omdata.design.inspect(args=None)[source]

A command-line entry point in order to list major fields of an input schema.

omdata.validator module

OpenMaker schema validator.

This module, until a fully custom version of it to be developed, uses jsonschema package for validation of survey response against openmaker design.

Example:
$ python validator.py -q ../docs/omsurvey.json -s ../docs/omsurvey.schema
Todo:
  • Do the Sphinx documentation
omdata.validator.check_file(survey_file, schema_file)[source]
Given external files the method checks validity of an input json file
against the schema file.
Args:
survey (string): A JSON data file. schema (string): A JSON schema file.
Returns:
(bool): True.
omdata.validator.check_json(survey, schema)[source]

The method checks validity of an input json against the schema.

Args:
survey (JSON): A JSON object. schema (JSON): A JSON schema.
Returns:
(bool): Returns True when it is validated.
omdata.validator.main(argv)[source]

The driver function when the module is run as a standalone python script.

Module contents