-
Notifications
You must be signed in to change notification settings - Fork 11
add(models): add AT model #588
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # | ||
| # Copyright (C) 2026 CERN. | ||
| # | ||
| # CDS-RDM is free software; you can redistribute it and/or modify it under | ||
| # the terms of the MIT License; see LICENSE file for more details. | ||
|
|
||
| from cds_migrator_kit.rdm.records.transform.models._config import IGNORE_SYSTEM_KEYS | ||
| from cds_migrator_kit.rdm.records.transform.models.base_publication_record import ( | ||
| rdm_base_publication_model, | ||
| ) | ||
| from cds_migrator_kit.transform.overdo import CdsOverdo | ||
|
|
||
|
|
||
| class ATModel(CdsOverdo): | ||
| """Translation model for AT records.""" | ||
|
|
||
| __query__ = """ | ||
| (980__:ARTICLE OR 980__:PREPRINT) | ||
| AND | ||
| (710__.5:NPA OR 710__.5:AT) | ||
| -710__.5:SI -710__.5:SC -710__.5:SL -710__.5:PS -710__.5:MPS -710__.5:ISR -710__.5:MSC -710__.5:AC -710__.5:SPS | ||
| -710__.5:LEP -710__.5:AB -710__.5:AR -710__.5:TS -710__.5:ST -710__.5:MT -710__.5:EST -710__.5:SB -710__.5:LHC | ||
| -980__:DELETED -980__c:MERGED | ||
| """ | ||
|
|
||
| __ignore_keys__ = IGNORE_SYSTEM_KEYS | { | ||
| "030__a", # coden designation | ||
| "260__b", # Always CERN | ||
| "300__b", # Resolution of the video | ||
| "340__a", # Physical medium | ||
| "518__h", # Start time of meeting/conference event | ||
| "518__g", # Meeting/conference identification | ||
| "520__9", # Source of the additional description (e.g. arxiv) | ||
| "542__3", # Part of the license | ||
| "595__i", # INSPEC number | ||
| "773__a", # Duplicate DOI | ||
| "901__u", # Affiliation at Conversion? | ||
| "913__y", # citation | ||
| "913__v", # citation | ||
| "913__t", # citation | ||
| "913__a", # citation | ||
| "913__c", # citation | ||
| "964__a", # number of physical copies | ||
| "970__b", # spreadsheet | ||
| } | ||
|
|
||
| _default_fields = { | ||
| "custom_fields": {}, | ||
| } | ||
|
|
||
|
|
||
| at_model = ATModel( | ||
| bases=(rdm_base_publication_model,), | ||
| entry_point_group="cds_migrator_kit.migrator.rules.at", | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # | ||
| # Copyright (C) 2026 CERN. | ||
| # | ||
| # CDS-RDM is free software; you can redistribute it and/or modify it under | ||
| # the terms of the MIT License; see LICENSE file for more details. | ||
| # | ||
| from dojson.errors import IgnoreKey | ||
|
|
||
| from cds_migrator_kit.transform.xml_processing.quality.decorators import ( | ||
| for_each_value, | ||
| require, | ||
| ) | ||
| from cds_migrator_kit.transform.xml_processing.quality.parsers import StringValue | ||
|
|
||
| from ...models.at import at_model as model | ||
|
|
||
|
|
||
| @model.over("contributors", "^541__") | ||
| @for_each_value | ||
| def contact_person(self, key, value): | ||
| contact_person = value.get("a", None) | ||
| if contact_person is None: | ||
| raise IgnoreKey("contributors") | ||
|
|
||
| contact_person = StringValue(contact_person).parse() | ||
|
|
||
| # Sometimes the contact person is stored as "<Name>, <Role>" where the role is some position within the project. | ||
| parts = contact_person.split(",") | ||
| if len(parts) == 2: | ||
| name, role = parts | ||
| contact_person = name.strip() | ||
|
|
||
| contributor = { | ||
| "person_or_org": { | ||
| "type": "personal", | ||
| "name": contact_person, | ||
| "family_name": contact_person, | ||
| }, | ||
| "role": {"id": "contactperson"}, | ||
| } | ||
| return contributor |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1056,10 +1056,25 @@ def imprint_info(self, key, value): | |
| if place: | ||
| imprint["place"] = place.rstrip(".") | ||
| self["custom_fields"]["imprint:imprint"] = imprint | ||
|
|
||
| if publication_date_str: | ||
| try: | ||
| publication_date = normalize(publication_date_str) | ||
| # Sometimes the imprint publication date ends with a "?" to mean that it's uncertain | ||
| # when the exact date was. | ||
| if "?" in publication_date_str: | ||
| publication_date_str = ( | ||
| publication_date_str.replace("?", "").rstrip("-").strip() | ||
| ) | ||
| self.setdefault("dates", []).append( | ||
| { | ||
| "description": "The publication date is indeterminate.", | ||
| "date": normalize(publication_date_str), | ||
| "type": {"id": "created"}, | ||
| } | ||
| ) | ||
|
|
||
| # TODO: should we still set as the main publication date if it's uncertain? | ||
| publication_date = normalize(publication_date_str) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we accept EDTF on publication date?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no we don't
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so the normalize strips it out? I think we having the extra date there at least we have some proof of the uncertainty. |
||
| self["publication_date"] = publication_date | ||
| except (ParserError, TypeError) as e: | ||
| raise UnexpectedValue( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we sure about these before curators see them? @kpsherva