遵守Proton的匹配评分库。
项目描述
LibProton
这是一个简化创建Proton兼容评分脚本的库。
它支持Python 3.7+。
安装
从PyPI 安装
pip install libproton
API
以下是一个完整且最简单的Proton兼容评分器,并展示了库的预期用法。
#!/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)
测试
运行 ./script/test
。
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码发行版
libproton-3.3.tar.gz (7.1 kB 查看哈希)
构建发行版
libproton-3.3-py2.py3-none-any.whl (8.8 kB 查看哈希)