@@ -288,7 +288,7 @@ def query(self,
288
288
if r .status_code == requests .codes .ok :
289
289
content = r .json ()
290
290
if content ["numFound" ] == 0 :
291
- # print ("No data was returned.")
291
+ logging . info ("No data was returned." )
292
292
data = "No data was returned."
293
293
prs = False
294
294
elif content ["numFound" ] > 0 and content ["numFound" ] <= 50 :
@@ -407,7 +407,9 @@ def search_procedure(self,
407
407
updated_since = updated_since ,
408
408
updated_until = updated_until ,
409
409
descriptor = descriptor ,
410
- sachgebiet = sachgebiet ,)
410
+ sachgebiet = sachgebiet ,
411
+ document_type = document_type ,
412
+ title = title )
411
413
return data
412
414
413
415
def get_procedure (self ,
@@ -504,7 +506,9 @@ def search_procedureposition(self,
504
506
date_end = date_end ,
505
507
num = num ,
506
508
updated_since = updated_since ,
507
- updated_until = updated_until ,)
509
+ updated_until = updated_until , ,
510
+ document_type = document_type ,
511
+ title = title )
508
512
return data
509
513
510
514
def get_procedureposition (self ,
@@ -618,7 +622,9 @@ def search_document(self,
618
622
institution = institution ,
619
623
num = num ,
620
624
updated_since = updated_since ,
621
- updated_until = updated_until ,)
625
+ updated_until = updated_until ,
626
+ document_type = document_type ,
627
+ title = title )
622
628
return data
623
629
624
630
def get_document (self ,
@@ -925,61 +931,4 @@ def list_methods(self):
925
931
"""
926
932
list_of_methods = dir (btaConnection )
927
933
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
- """
936
934
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 ()
0 commit comments