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+.
Install
Install from PyPI:
pip install libproton
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.3.tar.gz
(7.1 kB
view details)
Built Distribution
File details
Details for the file libproton-3.3.tar.gz
.
File metadata
- Download URL: libproton-3.3.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42f903a41f201a6fa2b8a5edde8c343db04f3037e6a9270c1c1382486acfc0e1 |
|
MD5 | b6afe7e3abb5a6bc4dc82f1ca0f54293 |
|
BLAKE2b-256 | d9ec13ca32148a042227ed4d0483ba6305f87a07759f37ddd524c0d6029b583d |
File details
Details for the file libproton-3.3-py2.py3-none-any.whl
.
File metadata
- Download URL: libproton-3.3-py2.py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfdb949ac8306ab0bd201472f651a046c33cc604de53e9c8151cb11d43b9b2a3 |
|
MD5 | 81e7afff76f053b546d81180544c9a69 |
|
BLAKE2b-256 | b11dc156cb46f83dd68c7313b1355b03d7158b790b70ae6af83c6b67c96083ba |