python-voting/README.md

62 lines
3.0 KiB
Markdown
Raw Permalink Normal View History

2023-04-02 14:48:27 +00:00
# Python-Voting
A Python 3.11 module for votings on the c-base space-station.
2023-04-03 11:44:06 +00:00
## Getting Started
```
git clone https://code.c-base.org/baccenfutter/python-voting
cd python-voting
poetry install
```
2023-04-02 14:48:27 +00:00
## Usage
```python
2023-04-03 11:53:12 +00:00
from voting import Quorum, QuorumKind, Vote, Voting, Result
2023-04-02 14:48:27 +00:00
# initializing a new voting
voting = Voting(
2023-04-03 03:07:00 +00:00
title="EXAMPLE",
quorum=Quorum(), # equals Quorum(kind=QuorumKind.NONE, value=None)
2023-04-02 14:48:27 +00:00
#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
2023-04-03 11:53:12 +00:00
res = Result(voting).result()
# printing the result
print(Result(voting))
2023-04-03 11:44:06 +00:00
```
## 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. │
2023-04-03 15:36:47 +00:00
│ vote Place a vote. │
2023-04-03 11:44:06 +00:00
╰────────────────────────────────────────────────────────────────────────────────────────────────────╯
$> voting new EXAMPLE_TITLE --quorum A:5 --voters a,b,c,d,e,f,g,h,i,j
2023-04-02 14:48:27 +00:00
```