Skip to content

Commit

Permalink
adding prefix as a parameter of write_oai.py, get_all_de.py, run_get_…
Browse files Browse the repository at this point in the history
…all_de_software.py and run_get_all_de_documents.py
  • Loading branch information
Mazztok45 committed Mar 4, 2024
1 parent 4c30ebe commit 4e89e3b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/zbmath_rest2oai/get_all_de.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
# from https://stackoverflow.com/a/38677619/9215209


def get_all_de(api_source, csv_url):
def get_all_de(api_source, csv_url, prefix):
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, api_source)
write_oai(de, api_source, prefix)
except Exception as error:
print(de, error, file=sys.stderr)

Expand Down
2 changes: 1 addition & 1 deletion src/zbmath_rest2oai/run_get_all_de_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
CSV_URL = 'https://github.com/MaRDI4NFDI/python-zbMathRest2Oai/releases/download/test/all_de_240115.csv'

if __name__ == '__main__':
get_all_de('https://api.zbmath.org/v1/document/',CSV_URL)
get_all_de('https://api.zbmath.org/v1/document/',CSV_URL, 'oai:zbmath.org:')
2 changes: 1 addition & 1 deletion src/zbmath_rest2oai/run_get_all_de_software.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

CSV_URL = 'https://raw.githubusercontent.com/MaRDI4NFDI/python-zbMathRest2Oai/main/src/zbmath_rest2oai/software.csv'
if __name__ == '__main__':
get_all_de('https://api.zbmath.org/v1/software/_search?search_string=si%3A',CSV_URL)
get_all_de('https://api.zbmath.org/v1/software/_search?search_string=si%3A',CSV_URL, 'oai:swmath.org:')
7 changes: 2 additions & 5 deletions src/zbmath_rest2oai/writeOai.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from zbmath_rest2oai import getAsXml


def write_oai(x, api_source):
prefix='oai:zbmath.org:'
if 'software' in api_source:
prefix='oai:swmath.org:'
def write_oai(x, api_source, prefix):
test_xml = getAsXml.final_xml2(x, api_source)
files = {
"item": (
Expand All @@ -38,4 +35,4 @@ def write_oai(x, api_source):
if __name__ == '__main__':
import sys

write_oai(sys.argv[1], sys.argv[2])
write_oai(sys.argv[1], sys.argv[2], sys.argv[3])

0 comments on commit 4e89e3b

Please sign in to comment.