Changeset View
Changeset View
Standalone View
Standalone View
swh/dataset/cli.py
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | ): | ||||
exclude_obj_types = {o.strip() for o in (exclude.split(",") if exclude else [])} | exclude_obj_types = {o.strip() for o in (exclude.split(",") if exclude else [])} | ||||
export_formats = [c.strip() for c in formats.split(",")] | export_formats = [c.strip() for c in formats.split(",")] | ||||
for f in export_formats: | for f in export_formats: | ||||
if f not in AVAILABLE_EXPORTERS: | if f not in AVAILABLE_EXPORTERS: | ||||
raise click.BadOptionUsage( | raise click.BadOptionUsage( | ||||
option_name="formats", message=f"{f} is not an available format." | option_name="formats", message=f"{f} is not an available format." | ||||
) | ) | ||||
# Enforce order (from origin to contents) to reduce number of holes in the graph. | |||||
object_types = [ | |||||
obj_type for obj_type in MAIN_TABLES.keys() if obj_type in object_types | |||||
] | |||||
def importcls(clspath): | def importcls(clspath): | ||||
mod, cls = clspath.split(":") | mod, cls = clspath.split(":") | ||||
m = import_module(mod) | m = import_module(mod) | ||||
return getattr(m, cls) | return getattr(m, cls) | ||||
exporter_cls = dict( | exporter_cls = dict( | ||||
(fmt, importcls(clspath)) | (fmt, importcls(clspath)) | ||||
for (fmt, clspath) in AVAILABLE_EXPORTERS.items() | for (fmt, clspath) in AVAILABLE_EXPORTERS.items() | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |