A Python module for votings on the c-base space-station.
Go to file
Brian Wiborg 0f43292863
📝 Small fixes.:wq
gi
2023-04-03 13:54:01 +02:00
test ♻️ Update tests 2023-04-03 13:47:55 +02:00
voting 🚸 Add CLI 2023-04-03 13:39:51 +02:00
.gitignore 🙈 Also mask backup file 2023-04-03 13:52:50 +02:00
poetry.lock 👔🙈📝 Add support for persistency 2023-04-03 13:38:59 +02:00
pyproject.toml 👔🙈📝 Add support for persistency 2023-04-03 13:38:59 +02:00
README.md 📝 Small fixes.:wq 2023-04-03 13:54:01 +02:00
TODO.md 👔🙈📝 Add support for persistency 2023-04-03 13:38:59 +02:00

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

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