提交 ca9a8d54 编写于 作者: W wuzewu

list command add table-like output

上级 761572f7
...@@ -21,6 +21,7 @@ from paddlehub.common import utils ...@@ -21,6 +21,7 @@ from paddlehub.common import utils
from paddlehub.common.downloader import default_downloader from paddlehub.common.downloader import default_downloader
from paddlehub.module.manager import default_module_manager from paddlehub.module.manager import default_module_manager
from paddlehub.commands.base_command import BaseCommand from paddlehub.commands.base_command import BaseCommand
from paddlehub.commands.cml_utils import TablePrinter
class ListCommand(BaseCommand): class ListCommand(BaseCommand):
...@@ -33,12 +34,10 @@ class ListCommand(BaseCommand): ...@@ -33,12 +34,10 @@ class ListCommand(BaseCommand):
def exec(self, argv): def exec(self, argv):
all_modules = default_module_manager.all_modules() all_modules = default_module_manager.all_modules()
list_text = "\n" tp = TablePrinter(titles=["ModuleName", "Path"], placeholders=[25, 50])
list_text += " %-20s\t\t%s\n" % ("ModuleName", "ModulePath")
list_text += " %-20s\t\t%s\n" % ("--", "--")
for module_name, module_dir in all_modules.items(): for module_name, module_dir in all_modules.items():
list_text += " %-20s\t\t%s\n" % (module_name, module_dir) tp.add_line(contents=[module_name, module_dir])
print(list_text) print(tp.get_text())
return True return True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册