Skip to content

Commit

Permalink
Add enrich_date enrichment method
Browse files Browse the repository at this point in the history
  • Loading branch information
amywieliczka committed Jul 22, 2024
1 parent a81f9f7 commit c17435c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions metadata_mapper/mappers/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,15 @@ def lookup(self, prop, target, substitution, inverse=[False]):
def enrich_earliest_date(self):
"""
Called 2794 times, never with any arguments
TODO: self.mapped_data is not guaranteed to be a dictionary,
according to pylance. Rather than wrap this in an
if isinstance(self.mapped_data, dict), I've added type: ignore
self.mapped_data is always a dictionary and should always be a
dictionary, so directionally, I'd rather resolve this by
figuring out why pylance thinks it could be otherwise and adding
clarity there.
"""
if "date" not in self.mapped_data:
return self
Expand All @@ -550,6 +559,29 @@ def enrich_earliest_date(self):

return self

def enrich_date(self, prop="sourceResource/temporal"):
"""
called 2,749 times with no arguments
called 1,003 times with prop=sourceResource/date
this is actually a duplicate of enrich_earliest_date, which
calls the same functions with an implicit prop="sourceResource/date"
there are only 3 collections that have enrich_date&prop=sourceResource/date
but DO NOT have a duplicative enrich_earliest_date call:
- 354: Adams (Peggy H.) papers
- 17210: Pierce (C.C.) Photographic Collection
- 26092: Bartlett (Adelbert) Papers
TODO: see comment in enrich_earliest_date regarding type: ignore
"""
prop = prop.split('/')[-1] # remove sourceResource
date_values = self.mapped_data.get(prop) # type: ignore
self.mapped_data[prop] = convert_dates(date_values) # type: ignore
check_date_format(
self.mapped_data['calisphere-id'], # type: ignore
self.mapped_data[prop] # type: ignore
)
return self

def enrich_location(self, prop=["sourceResource/spatial"]):
"""
the enrich_location.py file in dpla-ingestion includes the functions:
Expand Down

0 comments on commit c17435c

Please sign in to comment.