Skip to content

Commit

Permalink
refactoring code to make it more easily callable from a new main exec…
Browse files Browse the repository at this point in the history
…ution script run_get_all_de.py
  • Loading branch information
Mazztok45 committed Feb 8, 2024
1 parent 8ad13f9 commit 3ba531d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/zbmath_rest2oai/getAsXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
def final_xml2(de, api_source):

headers = {'Accept': 'application/json'}
api_source='https://api.zbmath.org/v1/document/'
r = requests.get(api_source + de, headers=headers)
if r.status_code != 200:
raise Exception(f"Unexpected response with status code {r.status_code}: {r.text}")
Expand Down
6 changes: 2 additions & 4 deletions src/zbmath_rest2oai/get_all_de.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
CSV_URL = 'https://github.com/MaRDI4NFDI/python-zbMathRest2Oai/releases/download/test/all_de_240115.csv'


def get_all_de():
def get_all_de(api_source):
with requests.get(CSV_URL, stream=True) as r:
lines = (line.decode('utf-8') for line in r.iter_lines())
for row in csv.reader(lines):
de = row[0]
try:
write_oai(de)
write_oai(de,api_source)
except Exception as error:
print(de, error, file=sys.stderr)


if __name__ == '__main__':
get_all_de()
5 changes: 5 additions & 0 deletions src/zbmath_rest2oai/run_get_all_de.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from zbmath_rest2oai.get_all_de import get_all_de


if __name__ == '__main__':
get_all_de('https://api.zbmath.org/v1/document/')

0 comments on commit 3ba531d

Please sign in to comment.