https://github.com/peterjclaw/libproton
A python library which simpliefies the creation of a Proton compliant scorer.
https://github.com/peterjclaw/libproton
srcomp
Last synced: 8 days ago
JSON representation
A python library which simpliefies the creation of a Proton compliant scorer.
- Host: GitHub
- URL: https://github.com/peterjclaw/libproton
- Owner: PeterJCLaw
- License: other
- Created: 2014-03-02T11:04:51.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T21:02:14.000Z (about 2 years ago)
- Last Synced: 2025-02-14T16:21:28.388Z (over 1 year ago)
- Topics: srcomp
- Language: Python
- Homepage: https://pypi.org/project/libproton/
- Size: 71.3 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LibProton
[](https://circleci.com/gh/PeterJCLaw/libproton)
This is a library which simplifies the task of creating
[Proton](https://github.com/PeterJCLaw/proton) compliant scoring scripts.
It supports Python 3.7+.
## Install
Install [from PyPI](https://pypi.org/project/libproton/):
``` shell
pip install libproton
```
## API
The following is a complete and minimal Proton compliant scorer, and shows
the expected usage of the library.
~~~~ python
#!/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`.