62 lines
3.0 KiB
Markdown
62 lines
3.0 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. │
|
|
│ vote Place a vote. │
|
|
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
|
|
|
$> voting new EXAMPLE_TITLE --quorum A:5 --voters a,b,c,d,e,f,g,h,i,j
|
|
``` |