Schema validations, migrations, and conversions to standardize the Ranked Choice Voting ecosystem
Project description
RCV Formats
A collection of parsers and converters from various RCV formats to the standard Universal RCV Tabulator format.
Validation
The following schemas can be validated. Currently, validation does not guarantee they can be imported: the validators make no sanity checks to ensure the math works out, or that there are no typos in candidate names. Rather, they only validate the structure.
- The Universal RCV Tabulator JSON format
- The Opavote JSON format
- The ElectionBuddy CSV format
You can run the validation and examine errors via:
from rcvformats.schemas import universaltabulator
schema = universaltabulator.SchemaV0()
is_valid = schema.validate_file('/path/to/file.json')
if not is_valid:
print(schema.get_last_error())
Valid schema validators are:
from rcvformats.schemas.electionbuddy import SchemaV0
from rcvformats.schemas.opavote import SchemaV1_0
from rcvformats.schemas.universaltabulator import SchemaV0
Conversion
You can convert from any of the supported formats and to the Universal RCV Tabulator format. The currently supported formats are:
- ElectionBuddy CSVs
- Opavote JSONs
You can run the conversion via:
from rcvformats.conversions import electionbuddy
converter = electionbuddy.ElectionBuddyConverter()
try:
converter.convert_to_ut(filename)
except Exception as e:
print("Errors: ", e)
Valid converters are:
from rcvformats.conversions.electionbuddy import ElectionBuddyConverter
from rcvformats.conversions.opavote import OpavoteConverter
Upcoming plans
- Allow any format to be converted both to and from the Universal Tabulator format
- Implement schema validation and migration for the ElectionBuddy CSV
- More unit tests
- Create both structure and data validations for the Universal Tabulator format
Running test suite
Just run nosetests
in the root directory
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
Built Distribution
Hashes for rcvformats-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d65502d0dec345f2b42ca23ff89f47c2afe79582a520a8b5f3ca4949d9a9ba3c |
|
MD5 | 44b55114ee690b6de20c7b80e3614982 |
|
BLAKE2b-256 | b6a32d3610b0f4a2afc89680e26b29479b18efbb146137f25500fd80a3144c55 |