Proton-compliant match scorer library.
Project description
LibProton
This is a library which simplifies the task of creating Proton compliant scoring scripts.
It supports Python 3.7+.
API
The following is a complete and minimal Proton compliant scorer, and shows the expected usage of the library.
#!/usr/bin/env python
import libproton
class Scorer:
def __init__(self, teams_data, arena_data):
self._teams_data = teams_data
self._arena_data = arena_data
def calculate_scores(self):
"""Main scoring entry point.
Expected to return a mapping of TLA -> score for each team in
the input data. Errors either in the input or otherwise should
be handled by raising exceptions.
"""
scores = {}
for tla in self._teams_data.keys():
scores[tla] = 4
return scores
def validate(self, extra_data):
"""An optional additional method to validate the scoresheet.
If this method is implemented it will be called with the value
of the ``other`` key from the input. If the key is not present
then this method will still be called (with ``None``).
If there are validation errors the this method should raise
an exception about them.
"""
pass
if __name__ == '__main__:
libproton.main(Scorer)
Tests
Run ./script/test
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
libproton-3.1.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for libproton-3.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c09b32be51fc8ac5aa7f8c92c57d0c0b43784d5d3c7b5805cf2570f5e98fc82 |
|
MD5 | b83d2afb568b8772909d07fc7eb7f19a |
|
BLAKE2b-256 | 1de356131a8ff32788fb6f8304ca2742303357a65485cd2141760e906ebfc226 |