Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/serializers.py
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | elif object_type == "skipped_content": | ||||
return {hash: getattr(object_, hash) for hash in DEFAULT_ALGORITHMS} | return {hash: getattr(object_, hash) for hash in DEFAULT_ALGORITHMS} | ||||
elif object_type == "origin": | elif object_type == "origin": | ||||
return {"url": object_.url} | return {"url": object_.url} | ||||
elif object_type == "origin_visit": | elif object_type == "origin_visit": | ||||
return { | return { | ||||
"origin": object_.origin, | "origin": object_.origin, | ||||
"date": str(object_.date), | "date": str(object_.date), | ||||
} | } | ||||
elif object_type == "origin_visit_status": | |||||
return { | |||||
"origin": object_.origin, | |||||
"visit": str(object_.visit), | |||||
"date": str(object_.date), | |||||
} | |||||
else: | else: | ||||
raise ValueError("Unknown object type: %s." % object_type) | raise ValueError("Unknown object type: %s." % object_type) | ||||
def stringify_key_item(k: str, v: Union[str, bytes]) -> str: | def stringify_key_item(k: str, v: Union[str, bytes]) -> str: | ||||
"""Turn the item of a dict key into a string""" | """Turn the item of a dict key into a string""" | ||||
if isinstance(v, str): | if isinstance(v, str): | ||||
return v | return v | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |