Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up models as dataclasses with xsdata #126

Open
2 tasks done
afuetterer opened this issue Nov 16, 2023 · 2 comments · May be fixed by #251
Open
2 tasks done

Set up models as dataclasses with xsdata #126

afuetterer opened this issue Nov 16, 2023 · 2 comments · May be fixed by #251
Labels
type: feature New feature or request
Milestone

Comments

@afuetterer
Copy link
Owner

afuetterer commented Nov 16, 2023

  • Set up models with xsdata:
python -m pip install xsdata[cli,lxml]
xsdata https://www.openarchives.org/OAI/2.0/OAI-PMH.xsd --package=models  --include-header --max-line-length=120 --docstring-style=Google --union-type  --postponed-annotations --structure-style=single-package
  • replace "Type" with ""
sed -i 's/Type//g' src/oaipmh_scythe/models/oai_pmh.py 

Figure this out:

  • Record is always part of oaipmh schema
  • metadata element depends on metadata format, that is used in request (oai_dc, datacite, etc.)
  • if params["metadata format"] == oai_dc, from models import oai_dc
  • how to parse metadata with model from other xsd schema, that is loaded at runtime?
  • has to happen in OAIItemIterator.__iter__() on the level of the individual record
    mapped = self.mapper(item)
  • if item.metadata do something

xsdata https://www.openarchives.org/OAI/2.0/OAI-PMH.xsd --package=models.oai_pmh --include-header --max-line-length=120 --docstring-style=Google --union-type --postponed-annotations --structure-style=single-package --slots --kw-only --subscriptable-types

Refs:

xsdata

schemas

htttp status code class

@afuetterer afuetterer added the type: feature New feature or request label Nov 16, 2023
@afuetterer afuetterer added this to the 0.10 milestone Nov 20, 2023
@afuetterer
Copy link
Owner Author

afuetterer commented Nov 24, 2023

xsdata http://www.openarchives.org/OAI/2.0/oai_dc.xsd --package=src.oaipmh_scythe.models.oai_dc  --include-header --max-line-length=120 --docstring-style=Google --union-type  --postponed-annotations --structure-style=single-package

@afuetterer afuetterer modified the milestones: 0.10, 0.11 Dec 13, 2023
@afuetterer afuetterer linked a pull request Jan 25, 2024 that will close this issue
25 tasks
@afuetterer afuetterer modified the milestones: 0.12, 0.13 Mar 16, 2024
@afuetterer
Copy link
Owner Author

afuetterer commented Apr 4, 2024

xsdata generate  \
  --config src/oaipmh_scythe/models/.xsdata.xml \
  --package src.oaipmh_scythe.models.oai_dc \
  http://www.openarchives.org/OAI/2.0/oai_dc.xsd
xsdata generate \
  --config src/oaipmh_scythe/models/.xsdata.xml \
  --package src.oaipmh_scythe.models.oai_pmh \
  https://www.openarchives.org/OAI/2.0/OAI-PMH.xsd

@afuetterer afuetterer modified the milestones: 0.13, 0.14 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant