Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/cli.py
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | def list(ctx, type): | ||||
"""List supported loaders and optionally their arguments""" | """List supported loaders and optionally their arguments""" | ||||
if type == "all": | if type == "all": | ||||
loaders = ", ".join(SUPPORTED_LOADERS) | loaders = ", ".join(SUPPORTED_LOADERS) | ||||
click.echo(f"Supported loaders: {loaders}") | click.echo(f"Supported loaders: {loaders}") | ||||
else: | else: | ||||
registry_entry = LOADERS[type].load()() | registry_entry = LOADERS[type].load()() | ||||
loader_cls = registry_entry["loader"] | loader_cls = registry_entry["loader"] | ||||
doc = inspect.getdoc(loader_cls).strip() | doc = inspect.getdoc(loader_cls).strip() | ||||
signature = inspect.signature(loader_cls) | |||||
click.echo(f"Loader: {doc}\nsignature: {signature}") | # Hack to get the signature of the class even though it subclasses | ||||
# Generic, which reimplements __new__. | |||||
# See <https://bugs.python.org/issue40897> | |||||
signature = inspect.signature(loader_cls.__init__) | |||||
signature_str = str(signature).replace("self, ", "") | |||||
click.echo(f"Loader: {doc}\nsignature: {signature_str}") |