python-voting/README.md
Brian Wiborg 0f43292863
📝 Small fixes.:wq
gi
2023-04-03 13:54:01 +02:00

61 lines
2.9 KiB
Markdown

# Python-Voting
A Python 3.11 module for votings on the c-base space-station.
## Getting Started
```
git clone https://code.c-base.org/baccenfutter/python-voting
cd python-voting
poetry install
```
## Usage
```python
from voting import Quorum, QuorumKind, Vote, Voting, Result
# initializing a new voting
voting = Voting(
title="EXAMPLE",
quorum=Quorum(), # equals Quorum(kind=QuorumKind.NONE, value=None)
#quorum=Quorum(kind=QuorumKind.ABSOLUTE, value=42),
#quorum=Quorum(kind=QuorumKind.PERCENT, value=42.0),
voters=['alice', 'bob'],
)
# placing a vote
voting.vote('alice', Vote.NO)
# overwrite an existing vote
voting.vote('alice', Vote.YES)
# obtaining the result
res = Result(voting).result()
# printing the result
print(Result(voting))
```
## Command-line Interface
```
$> voting --help
Usage: voting [OPTIONS] COMMAND [ARGS]...
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy it or customize the │
│ installation. │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────╮
│ ls List all votings. │
│ new Create a new voting. │
│ rm Delete a voting. │
│ show Display the results of a voting. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
$> voting new EXAMPLE_TITLE --quorum A:5 --voters a,b,c,d,e,f,g,h,i,j
```