Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/checks.py
Show All 24 Lines | def check_metadata(metadata: Dict) -> Tuple[bool, Optional[Dict]]: | ||||
Returns: | Returns: | ||||
tuple (status, error_detail): True, None if metadata are | tuple (status, error_detail): True, None if metadata are | ||||
ok (False, <detailed-error>) otherwise. | ok (False, <detailed-error>) otherwise. | ||||
""" | """ | ||||
# following fields are mandatory | # following fields are mandatory | ||||
required_fields = { | required_fields = { | ||||
"author": False, | "atom:author": False, | ||||
} | } | ||||
# at least one value per couple below is mandatory | # at least one value per couple below is mandatory | ||||
alternate_fields = { | alternate_fields = { | ||||
("name", "title"): False, | ("atom:name", "atom:title"): False, | ||||
} | } | ||||
for field, value in metadata.items(): | for field, value in metadata.items(): | ||||
for name in required_fields: | for name in required_fields: | ||||
if name in field: | if name in field: | ||||
required_fields[name] = True | required_fields[name] = True | ||||
for possible_names in alternate_fields: | for possible_names in alternate_fields: | ||||
Show All 18 Lines |