Schemas¶
Interface¶
All schemas conform to this interface.
Loads supported schemas (currently only one: the Universal Tabulator schema)
- class schemas.base.Schema¶
Bases:
ABC
A single version of a single schema
- last_error()¶
If validate() failed, this method will provide more detailed information on the error. The details vary by class type, though it will always be of type Exception
- Returns:
Exception with additional information on why the validation failed
- validate(data)¶
Validates that the file matches the expected schema
- Parameters:
data – The JSON filename, file object, or JSON data for the tabulated results
- Returns:
whether or not the validation failed
- abstract version()¶
The version number of this schema
- Returns:
A string represting the version number
Internal developer documentation¶
The remainder of this documentation is about the internal representation of classes. It is intended for developers of RCV Formats, rather than its users.
JSONSchema helper¶
A helper interface for all jsonschema-backed schemas
Loads supported schemas (currently only one: the Universal Tabulator schema)
- class schemas.base.GenericJsonSchema
Bases:
Schema
Base class for a JSON Schema
- ensure_data_is_logical(data)
Override to add any additional data validations you need done. Raise an exception if anything is invalid
- is_data_valid(data)
Additional validations to ensure the data is correct.
- Parameters:
data – The input dictionary, which must match the schema
- Returns:
Whether or not the data is acceptable
- is_schema_valid(data)
Validates that the data matches the schema. If invalid, more data may be available by calling last_error()
- Parameters:
data – The input dictionary
- Returns:
Whether or not the data matches the schema
- abstract property schema_filename
The JSON Schema filename
- validate_schema_and_logic(data)
Runs both the schema and logic check
Universal Tabulator¶
Loads the universal tabulator schema
- class schemas.universaltabulator.SchemaV0¶
Bases:
GenericJsonSchema
Schema for the initial version of the Universal RCV Tabulator
- classmethod check_candidate_leaves_after_elimination(data)¶
After a candidate is eliminated, ensure they are not listed later as having zero votes. They should be removed from the list.
- classmethod check_last_round_eliminations(data)¶
No eliminations allowed on the last round
- classmethod check_no_empty_candidate_names(data)¶
All candidate names must be unique
- classmethod check_unique_candidate_names(data)¶
All candidate names must be unique
- ensure_data_is_logical(data)¶
Various checks to ensure the data is sane - though it cannot catch everything, we have tried to place the most common errors here
- property schema_filename¶
The JSON Schema filename
- version()¶
The version number of this schema
- Returns:
A string represting the version number
Opavote¶
Loads the opavote schema