Delete tools/get_active_fractions.py
Browse files
tools/get_active_fractions.py
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
from typing import List, Dict
|
2 |
-
import tkapi
|
3 |
-
from tkapi.fractie import Fractie
|
4 |
-
|
5 |
-
def Get_Active_Fractions() -> List[Dict[str, str | int]]:
|
6 |
-
"""
|
7 |
-
Retrieves a list of all currently active fractions (political parties) in the Dutch parliament.
|
8 |
-
|
9 |
-
Returns:
|
10 |
-
List[Dict[str, Union[str, int]]]: A list of dictionaries containing information about each fraction:
|
11 |
-
- 'naam': Full name of the political party (string)
|
12 |
-
- 'afkorting': Abbreviation/acronym of the party (string)
|
13 |
-
- 'zetels_aantal': Number of seats the party holds (integer)
|
14 |
-
|
15 |
-
Example return value:
|
16 |
-
[
|
17 |
-
{
|
18 |
-
'naam': 'Volkspartij voor Vrijheid en Democratie',
|
19 |
-
'afkorting': 'VVD',
|
20 |
-
'zetels_aantal': 34
|
21 |
-
},
|
22 |
-
{
|
23 |
-
'naam': 'Democraten 66',
|
24 |
-
'afkorting': 'D66',
|
25 |
-
'zetels_aantal': 24
|
26 |
-
}
|
27 |
-
]
|
28 |
-
|
29 |
-
Note:
|
30 |
-
This tool connects to the official Dutch Parliament API to fetch real-time data.
|
31 |
-
The number of seats and active fractions may change over time.
|
32 |
-
"""
|
33 |
-
try:
|
34 |
-
# Initialize API client
|
35 |
-
api = tkapi.TKApi(verbose=False)
|
36 |
-
|
37 |
-
# Create filter for active fractions
|
38 |
-
filter = Fractie.create_filter()
|
39 |
-
filter.filter_actief()
|
40 |
-
|
41 |
-
# Get all active fractions
|
42 |
-
active_fractions = api.get_fracties(filter=filter)
|
43 |
-
|
44 |
-
# Format the results
|
45 |
-
results = []
|
46 |
-
for fraction in active_fractions:
|
47 |
-
fraction_info = {
|
48 |
-
'naam': fraction.naam,
|
49 |
-
'afkorting': fraction.afkorting,
|
50 |
-
'zetels_aantal': fraction.zetels_aantal
|
51 |
-
}
|
52 |
-
results.append(fraction_info)
|
53 |
-
|
54 |
-
return results
|
55 |
-
|
56 |
-
except Exception as e:
|
57 |
-
print(f"Error fetching fraction data: {str(e)}")
|
58 |
-
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|