Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/metadata_dictionary/__init__.py
Show All 21 Lines | for mapping in MAPPINGS.values(): | ||||
for term in mapping.supported_terms(): | for term in mapping.supported_terms(): | ||||
d[term].add(mapping) | d[term].add(mapping) | ||||
return d | return d | ||||
@click.command() | @click.command() | ||||
@click.argument("mapping_name") | @click.argument("mapping_name") | ||||
@click.argument("file_name") | @click.argument("file_name") | ||||
def main(mapping_name, file_name): | def main(mapping_name: str, file_name: str): | ||||
from pprint import pprint | from pprint import pprint | ||||
with open(file_name, "rb") as fd: | with open(file_name, "rb") as fd: | ||||
file_content = fd.read() | file_content = fd.read() | ||||
res = MAPPINGS[mapping_name]().translate(file_content) | res = MAPPINGS[mapping_name]().translate(file_content) | ||||
pprint(res) | pprint(res) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
main() | main() |