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

Fix cleanup_value enrichment #532

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions metadata_mapper/mappers/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,20 +1145,18 @@ def cleanup_value(self):
"""
2076 times: no parameters
"""
# Previously in default fields, not sure how they map to new system:
# "sourceResource/collection/title",
# "sourceResource/collection/description",
# "sourceResource/contributor", "sourceResource/spatial/name"
default_fields = [
"sourceResource/language", "sourceResource/title",
"sourceResource/creator", "sourceResource/relation",
"sourceResource/publisher", "sourceResource/subject",
"sourceResource/date",
"sourceResource/collection/title",
"sourceResource/collection/description",
"sourceResource/contributor", "sourceResource/spatial/name"
]
dont_strip_trailing_dot = [
"hasView/format", "sourceResource/format", "sourceResource/extent",
"sourceResource/rights",
"sourceResource/place", "sourceResource/collection/title"
"language", "title", "creator", "relation",
"publisher", "subject", "date",
]
# Previously in dont strip trailing dot fields,
# not sure how they map to new system:
# "hasView/format", "sourceResource/collection/title"
dont_strip_trailing_dot = ["format", "extent", "rights", "place"]

def cleanup(value, field):
strip_dquote = '"' if field not in ["title", "description"] else ''
Expand All @@ -1180,9 +1178,6 @@ def cleanup(value, field):
return value

for field in default_fields + dont_strip_trailing_dot:
# TODO: this won't work for deeply nested fields
field.split('/')[1] # remove sourceResource

if field not in self.mapped_data:
continue
if isinstance(self.mapped_data[field], str):
Expand Down