Skip to content

Commit 6cebc62

Browse files
authored
Merge pull request #11 from jschibberges/dev
Version 1.0.5
2 parents c79fe0b + 46f2915 commit 6cebc62

File tree

4 files changed

+14
-71
lines changed

4 files changed

+14
-71
lines changed

bundestag_api/bta_wrapper.py

+10-61
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def query(self,
288288
if r.status_code == requests.codes.ok:
289289
content = r.json()
290290
if content["numFound"] == 0:
291-
# print("No data was returned.")
291+
logging.info("No data was returned.")
292292
data = "No data was returned."
293293
prs = False
294294
elif content["numFound"] > 0 and content["numFound"] <= 50:
@@ -407,7 +407,9 @@ def search_procedure(self,
407407
updated_since=updated_since,
408408
updated_until=updated_until,
409409
descriptor=descriptor,
410-
sachgebiet=sachgebiet,)
410+
sachgebiet=sachgebiet,
411+
document_type=document_type,
412+
title=title)
411413
return data
412414

413415
def get_procedure(self,
@@ -504,7 +506,9 @@ def search_procedureposition(self,
504506
date_end=date_end,
505507
num=num,
506508
updated_since=updated_since,
507-
updated_until=updated_until,)
509+
updated_until=updated_until,,
510+
document_type=document_type,
511+
title=title)
508512
return data
509513

510514
def get_procedureposition(self,
@@ -618,7 +622,9 @@ def search_document(self,
618622
institution=institution,
619623
num=num,
620624
updated_since=updated_since,
621-
updated_until=updated_until,)
625+
updated_until=updated_until,
626+
document_type=document_type,
627+
title=title)
622628
return data
623629

624630
def get_document(self,
@@ -925,61 +931,4 @@ def list_methods(self):
925931
"""
926932
list_of_methods = dir(btaConnection)
927933
list_of_methods = [item for item in list_of_methods if "__" not in item]
928-
"""
929-
list_of_methods = ["get_activity","search_activity","get_person",
930-
"search_person", "get_plenaryprotocol",
931-
"search_plenaryprotocol", "get_document",
932-
"search_document", "get_procedureposition",
933-
"search_procedureposition", "get_procedure",
934-
"search_procedure", "query"]
935-
"""
936934
return list_of_methods
937-
938-
939-
def main_function():
940-
arguments = parse_args_to_dict(sys.argv[1:])
941-
if arguments.get("o") is not None:
942-
output_format = arguments.get("o")
943-
output_defined = True
944-
arguments.pop("o")
945-
if arguments.get("n") is not None:
946-
file_name = arguments.get("n")
947-
if output_format not in file_name:
948-
file_name = file_name+"."+output_format
949-
arguments.pop("n")
950-
else:
951-
raise ValueError("Output defined but no filename given.")
952-
if arguments.get("apikey") is not None:
953-
bta = btaConnection(apikey=arguments.get("apikey"))
954-
arguments.pop("apikey")
955-
else:
956-
bta = btaConnection()
957-
if arguments.get("method") is not None:
958-
if arguments.get("method") in bta.list_methods():
959-
method = arguments.get("method")
960-
arguments.pop("method")
961-
if method == "searchProcedure":
962-
data = bta.search_procedure(arguments)
963-
else:
964-
raise ValueError("No valid method supplied.")
965-
else:
966-
raise ValueError("No method supplied")
967-
if output_defined == True:
968-
if output_format == "xlsx" or output_format == "xls":
969-
import pandas as pd
970-
data = pd.json_normalize(data)
971-
data.to_excel(file_name, index=False)
972-
elif output_format == "csv":
973-
import pandas as pd
974-
data = pd.json_normalize(data)
975-
data.to_csv(file_name, index=False)
976-
elif output_format == "json":
977-
import json
978-
with open(file_name, 'w', encoding='utf-8') as f:
979-
json.dump(data, f, ensure_ascii=False, indent=4)
980-
else:
981-
return data
982-
983-
984-
if __name__ == "__main__":
985-
main_function()

bundestag_api/models.py

-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
Created on Fri Mar 1 22:45:35 2024
4-
5-
@author: jschi
6-
"""
7-
8-
# Classes
9-
102

113
class Person:
124
"""This class represents a German parliamentarian"""

requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
requests>2.0.0
1+
openpyxl>3.0.0
2+
pandas>1.2.0
3+
requests>2.0.0

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
readme="README.md",
1717
license="MIT",
1818
name='bundestag_api',
19-
version='1.0.4',
19+
version='1.0.5',
2020
packages=find_packages(),
2121
install_requires=[
2222
'requests>=2.0.0',

0 commit comments

Comments
 (0)