Skip to content

Commit

Permalink
advancing work on processing codemeta from OAI-PMH to be deposited
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazztok45 committed Dec 9, 2024
1 parent 0f112b0 commit 610cf10
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/swmath2swh/convertSoftware_from_json_toXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def json_to_xml(json_data):
# Add references
references_elem = ET.SubElement(root, 'references')
for ref in result.get('references', []):
reference_elem = ET.SubElement(references_elem, 'reference')
reference_elem = ET.SubElement(references_elem, 'references')
reference_elem.text = str(ref)

return root
Expand Down
18 changes: 11 additions & 7 deletions src/swmath2swh/staging_deposit_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@
import time
import tempfile
import os
import requests

env = os.environ.copy()
env['SWMATH_USER_DEPOSIT'] = os.getenv('SWMATH_USER_DEPOSIT')
env['SWMATH_PWD_DEPOSIT'] = os.getenv('SWMATH_PWD_DEPOSIT')
env['SWMATH_PWD_DEPOSIT'] = os.getenv('SWMATH_PWD_DEPOSIT')

import requests
xsl_filename = '../xslt/software/xslt_SWH_deposit.xslt'

r = requests.get("https://oai.staging.mardi4nfdi.org/oai/OAIHandler?verb=GetRecord&metadataPrefix=codemeta&identifier=oai:swmath.org:4532")

xml = r.text


xml_str = r.content
dom = ET.fromstring(xml_str)
xslt = ET.parse(xsl_filename)
transform = ET.XSLT(xslt)
newdom = transform(dom)
formatted_newdom = ET.tostring(newdom, pretty_print=True, encoding='unicode')

# Add this before the write statement
# Write transformed XML to a temporary file
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.xml') as temp_file:
temp_file.write(xml)
temp_file.write(formatted_newdom)
temp_filename = temp_file.name
print(f"Temporary file created: {temp_filename}")
# Format current time for deposit status
Expand Down
Empty file.

0 comments on commit 610cf10

Please sign in to comment.