Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/utils.py
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | Returns | ||||
The swh date object | The swh date object | ||||
""" | """ | ||||
if isinstance(date, list): | if isinstance(date, list): | ||||
date = date[0] | date = date[0] | ||||
if isinstance(date, str): | if isinstance(date, str): | ||||
date = iso8601.parse_date(date) | date = iso8601.parse_date(date) | ||||
return TimestampWithTimezone.from_dict(date).to_dict() | d = TimestampWithTimezone.from_dict(date).to_dict() | ||||
# Workaround while we migrate from storing offsets as (int, bool) to bytes. | |||||
# When the migration is done, remove this pop(). | |||||
# offset_bytes will also need to be converted to a string (which is fine because | |||||
# it is always a well-formed offset) | |||||
d.pop("offset_bytes", None) | |||||
return d | |||||
def compute_metadata_context(swhid_reference: QualifiedSWHID) -> Dict[str, Any]: | def compute_metadata_context(swhid_reference: QualifiedSWHID) -> Dict[str, Any]: | ||||
"""Given a SWHID object, determine the context as a dict. | """Given a SWHID object, determine the context as a dict. | ||||
""" | """ | ||||
metadata_context: Dict[str, Any] = {"origin": None} | metadata_context: Dict[str, Any] = {"origin": None} | ||||
if swhid_reference.qualifiers(): | if swhid_reference.qualifiers(): | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |