Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/storage/converters.py
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | return { | ||||
} | } | ||||
} | } | ||||
def db_to_metadata(metadata): | def db_to_metadata(metadata): | ||||
"""Convert a metadata entry into a ready metadata output. | """Convert a metadata entry into a ready metadata output. | ||||
""" | """ | ||||
return { | metadata['tool'] = { | ||||
'id': metadata['id'], | |||||
'translated_metadata': metadata['translated_metadata'], | |||||
'tool': { | |||||
'id': metadata['tool_id'], | 'id': metadata['tool_id'], | ||||
'name': metadata['tool_name'], | 'name': metadata['tool_name'], | ||||
'version': metadata['tool_version'], | 'version': metadata['tool_version'], | ||||
'configuration': metadata['tool_configuration'] | 'configuration': metadata['tool_configuration'] | ||||
} | } | ||||
} | del metadata['tool_id'], metadata['tool_configuration'] | ||||
del metadata['tool_version'], metadata['tool_name'] | |||||
ardumont: For my information, is this more pythonic to do it that way instead of the previous one? | |||||
Done Inline ActionsI changed the semantic to keep all keys that are not explicitly handled, eg. metadata vs translated_metadata. vlorentz: I changed the semantic to keep all keys that are not explicitly handled, eg. `metadata` vs… | |||||
return metadata | |||||
def db_to_fossology_license(license): | def db_to_fossology_license(license): | ||||
return { | return { | ||||
'licenses': license['licenses'], | 'licenses': license['licenses'], | ||||
'tool': { | 'tool': { | ||||
'id': license['tool_id'], | 'id': license['tool_id'], | ||||
'name': license['tool_name'], | 'name': license['tool_name'], | ||||
'version': license['tool_version'], | 'version': license['tool_version'], | ||||
'configuration': license['tool_configuration'], | 'configuration': license['tool_configuration'], | ||||
} | } | ||||
} | } |
For my information, is this more pythonic to do it that way instead of the previous one?