Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bohdanbobrowski/pyrlament
Python library for counting and visualizing seats in the Sejm of the Republic of Poland
https://github.com/bohdanbobrowski/pyrlament
dhondt dhont-method election elections-2019 elections-2023 kalkulator kalkulator-sejmowy parliament python python3 sejm wybory
Last synced: about 1 month ago
JSON representation
Python library for counting and visualizing seats in the Sejm of the Republic of Poland
- Host: GitHub
- URL: https://github.com/bohdanbobrowski/pyrlament
- Owner: bohdanbobrowski
- License: mit
- Created: 2022-02-14T21:17:42.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T08:20:12.000Z (about 1 year ago)
- Last Synced: 2023-10-20T15:26:36.208Z (about 1 year ago)
- Topics: dhondt, dhont-method, election, elections-2019, elections-2023, kalkulator, kalkulator-sejmowy, parliament, python, python3, sejm, wybory
- Language: Python
- Homepage: https://www.pyrlament.pl
- Size: 10.5 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
[![Licence](https://img.shields.io/github/license/Ileriayo/markdown-badges?style=for-the-badge)](./LICENSE)
![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)
![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)# pyRLAMENT
Python library for visualizing seats in the Sejm of the Republic of Poland. So far still in development. Its main goal is to practice the capabilities of Python on various platforms (web/mobile/desktop).
## SeatsCounter:
from pyrlament import SeatsCounter
from pyrlament.data import Partyelection2019 = {
Party(name="PiS", support=43.59, threshold=8),
Party(name="KO", support=27.4, threshold=8),
Party(name="Lewica", support=12.56),
Party(name="PSL", label="Polska 2050-PSL", support=10.8, threshold=8, color="DCB44B"),
Party(name="Konfederacja", support=6.81),
}
election = SeatsCounter(parties=election2019)
election.count()As a result of the operation of the `count` method, the `parties` parameter will contain information about the seats in the parliament, ex.:
for party in election.parties:
print(f"{party.name}: {party.seats}")...should print:
PiS: 235,
KO: 134,
Lewica: 49,
PSL: 30
Konfederacja: 11
Mniejszość niemiecka: 1## SeatsGenerator:
from pyrlament import SeatsGenerator
g = SeatsGenerator(parties=election.parties)
g.randomize()
with open('pyrlament.svg', 'w') as f:
f.write(g.svg())#### SVG example:
#### PNG example:
Known bug: for some reason png output is missing logotype.
## Tests coverage
|Module|statements|missing|excluded|coverage|
|------|----------|-------|--------|--------|
|pyrlament/__init__.py|4|0|0|100%|
|pyrlament/configs.py|13|0|0|100%|
|pyrlament/counter.py|93|0|0|100%|
|pyrlament/data.py|68|0|0|100%|
|pyrlament/generator.py|289|167|0|42%|
|Total|467|167|0|64%|## Implemented and planned features
Here are my plans (some already implemented) for this library:
- [x] count seats basing on election support
- [x] cover code with unit tests
- [x] 5% and 8% support threshold
- [ ] check if all support does not reach 100%
- [x] draw svg with seats
- [x] randomise seats colors
- [x] split seats between parties
- [ ] improve seats placement (it's a bit messy)
- [x] svg output
- [x] fix png output (I've implemented workaround)
- [x] [build webapp using Flask](https://www.pyrlament.pl)
- [ ] build mobile app using Kivy
- [ ] build desktop app using Kivy
- [ ] cli interface for library