Skip to content

Commit

Permalink
Merge branch 'main' into XSLT_Shiraz
Browse files Browse the repository at this point in the history
  • Loading branch information
physikerwelt committed Feb 22, 2024
2 parents 7aa54f2 + 1152b50 commit 73d2153
Show file tree
Hide file tree
Showing 34 changed files with 561 additions and 596 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
coverage run -m pytest
coverage report -m
- name: Test & publish code coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageCommand: coverage xml
debug: true
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# python-zbMathRest2Oai

[![DeepSource](https://app.deepsource.com/gh/MaRDI4NFDI/python-zbMathRest2Oai.svg/?label=resolved+issues&show_trend=true&token=SovMnB53sVw8-JcWeL8YRnsG)](https://app.deepsource.com/gh/MaRDI4NFDI/python-zbMathRest2Oai/) [![SWH](https://archive.softwareheritage.org/badge/origin/https://github.com/MaRDI4NFDI/python-zbMathRest2Oai/)](https://archive.softwareheritage.org/browse/origin/?origin_url=https://github.com/MaRDI4NFDI/python-zbMathRest2Oai) [![Maintainability](https://api.codeclimate.com/v1/badges/88fa012874c78bfeb8bf/maintainability)](https://codeclimate.com/github/MaRDI4NFDI/python-zbMathRest2Oai/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/88fa012874c78bfeb8bf/test_coverage)](https://codeclimate.com/github/MaRDI4NFDI/python-zbMathRest2Oai/test_coverage)

Read data from the zbMATH Open API https://api.zbmath.org/docs and feed it to the OAI-PMH server https://oai.portal.mardi4nfdi.de/oai/

Hint for a proper installation:

_ point to the directory
_ execute "pip install -e ."
_ execute "pip install -e ."
79 changes: 79 additions & 0 deletions codemeta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"codeRepository": "https://github.com/MaRDI4NFDI/python-zbMathRest2Oai",
"contIntegration": "https://github.com/MaRDI4NFDI/python-zbMathRest2Oai/blob/main/.github/workflows/python-app.yml",
"dateCreated": "2024-02-13",
"datePublished": "2024-02-13",
"dateModified": "2024-02-13",
"downloadUrl": "https://github.com/MaRDI4NFDI/python-zbMathRest2Oai/archive/refs/heads/main.zip",
"issueTracker": "https://github.com/MaRDI4NFDI/python-zbMathRest2Oai/issues",
"name": "python-zbMathRest2Oai",
"version": "1.0.0",
"identifier": "swh:1:dir:de327a8f9f82353f91c8dbbdd3f54d1efb3ba04e",
"description": "Read data from the zbMATH Open API https://api.zbmath.org/docs and feed it to the OAI-PMH server https://oai.portal.mardi4nfdi.de/oai/",
"releaseNotes": "This is the first codemeta file we create, and should be considered as a prototype for the future beta integration in the faircore4eosc.",
"developmentStatus": "wip",
"isPartOf": "https://portal.mardi4nfdi.de/wiki/Portal",
"funder": {
"@type": "Organization",
"name": "FIZ Karlstruhe"
},
"keywords": [
"zbmath",
"swmath",
"EOSC",
"PIDGraph",
"RDGraph",
"RSAC"
],
"programmingLanguage": [
"Python3",
"XSLT",
"shell"
],
"operatingSystem": [
"Linux"
],
"softwareRequirements": [
"Python 3.9"
],
"relatedLink": [
"https://faircore4eosc.eu/"
],
"author": [
{
"@type": "Person",
"@id": "https://orcid.org/0000-0002-8710-9548",
"givenName": "Maxence",
"familyName": "Azzouz-Thuderoz",
"email": "[email protected]",
"affiliation": {
"@type": "Organization",
"name": "Department of Mathematics, FIZ Karlsruhe"
}
},
{
"@type": "Person",
"@id": "https://orcid.org/0009-0005-1697-3282",
"givenName": "Shiraz",
"familyName": "Malla Mohamad",
"email": "[email protected]",
"affiliation": {
"@type": "Organization",
"name": "Department of Mathematics, FIZ Karlsruhe"
}
},
{
"@type": "Person",
"@id": "https://orcid.org/0000-0001-7141-4997",
"givenName": "Moritz",
"familyName": "Schubotz",
"email": "[email protected]",
"affiliation": {
"@type": "Organization",
"name": "Department of Mathematics, FIZ Karlsruhe"
}
}
]
}
4 changes: 4 additions & 0 deletions formats/createFormats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ curl --noproxy '*' -X POST -H 'Content-Type: application/json' -H "Authorizatio
printf "\n\nCreate Format datacite\n\n"
curl --noproxy '*' -X POST -H 'Content-Type: application/json' -H "Authorization: Basic $AUTH" -i 'https://oai-input.portal.mardi4nfdi.de/oai-backend/format' --data '{"metadataPrefix":"oai_zb_preview","schemaLocation":"https://zbmath.org/OAI/2.0/oai_zb_preview/","schemaNamespace":"https://zbmath.org/zbmath/elements/1.0/","identifierXpath":""}'
printf "\n\n Read all formats\n\n"
curl --noproxy '*' -X POST -H 'Content-Type: application/json' -H "Authorization: Basic $AUTH" -i 'https://oai-input.portal.mardi4nfdi.de/oai-backend/format' --data '{"metadataPrefix":"zbmath_rest_api","schemaLocation":"https://github.com/MaRDI4NFDI/python-zbMathRest2Oai/blob/main/tests/data/plain.xml","schemaNamespace":"https://github.com/MaRDI4NFDI/python-zbMathRest2Oai/blob/main/tests/data/","identifierXpath":""}'
printf "\n\nCreate Format zbmath_rest_api\n\n"


curl --noproxy '*' -X GET -H "Authorization: Basic $AUTH" 'https://oai-input.portal.mardi4nfdi.de/oai-backend/format'
87 changes: 0 additions & 87 deletions json mapping/mapping restoai.md

This file was deleted.

84 changes: 0 additions & 84 deletions json mapping/output mapping.json

This file was deleted.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ dynamic = ["version"]
dependencies = [
"dict2xml",
"requests",
"swagger_client @ git+https://github.com/zbMATHOpen/zbRestApiClient.git"
]
[project.optional-dependencies]
test = [
"black",
"coverage",
"flake8",
"isort",
"pytest",
Expand All @@ -26,7 +26,8 @@ test = [
"requests_mock",
"python-dateutil",
"pytest-coverage",
"xmldiff"
"xmldiff",
"lxml"
]

[tool.setuptools]
Expand Down
Binary file modified requirements.txt
Binary file not shown.
6 changes: 6 additions & 0 deletions src/zbmath_rest2oai/fake_dict_sw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def fake_dict_sw():
with open('software.csv','w') as f:
return f.write("\n".join(map(str,list(range(2, 10)))))

if __name__ == '__main__':
fake_dict_sw()
19 changes: 10 additions & 9 deletions src/zbmath_rest2oai/getAsXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@
import requests


def final_xml2(de):
def final_xml2(de, api_source):

headers = {'Accept': 'application/json'}

r = requests.get('https://api.zbmath.org/v1/document/' + de, headers=headers)
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}")
json = r.json()
# Bugfix as the sates are lists of lists which has no canonical XML mapping
states = {}
for lst in json['result']['states']:
[k, v] = lst
states[k] = v
json['result']['states'] = states
if type(json['result'])==dict:

states = {}
for lst in json['result']['states']:
[k, v] = lst
states[k] = v
json['result']['states'] = states
# End of fix
return (
dict2xml.Converter(wrap="root")
.build(json, closed_tags_for=[
# Bugfix for wired XML output such as the string None or </>
[], '', [None], None
])
)
)
Loading

0 comments on commit 73d2153

Please sign in to comment.