diff --git a/paddlehub/commands/list.py b/paddlehub/commands/list.py index 395ae489748480b2efa454715a7e517a252a1c92..fc15ba25758b345689c38bab0663d513575a8a28 100644 --- a/paddlehub/commands/list.py +++ b/paddlehub/commands/list.py @@ -21,6 +21,7 @@ from paddlehub.common import utils from paddlehub.common.downloader import default_downloader from paddlehub.module.manager import default_module_manager from paddlehub.commands.base_command import BaseCommand +from paddlehub.commands.cml_utils import TablePrinter class ListCommand(BaseCommand): @@ -33,12 +34,10 @@ class ListCommand(BaseCommand): def exec(self, argv): all_modules = default_module_manager.all_modules() - list_text = "\n" - list_text += " %-20s\t\t%s\n" % ("ModuleName", "ModulePath") - list_text += " %-20s\t\t%s\n" % ("--", "--") + tp = TablePrinter(titles=["ModuleName", "Path"], placeholders=[25, 50]) for module_name, module_dir in all_modules.items(): - list_text += " %-20s\t\t%s\n" % (module_name, module_dir) - print(list_text) + tp.add_line(contents=[module_name, module_dir]) + print(tp.get_text()) return True