Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
7b4b4356
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
281
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7b4b4356
编写于
4月 10, 2019
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix command line output format bug in windows
上级
0b42516f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
7 deletion
+51
-7
paddlehub/commands/cml_utils.py
paddlehub/commands/cml_utils.py
+20
-3
paddlehub/commands/list.py
paddlehub/commands/list.py
+6
-1
paddlehub/commands/search.py
paddlehub/commands/search.py
+5
-1
paddlehub/commands/show.py
paddlehub/commands/show.py
+11
-2
paddlehub/common/utils.py
paddlehub/common/utils.py
+9
-0
未找到文件。
paddlehub/commands/cml_utils.py
浏览文件 @
7b4b4356
...
...
@@ -16,7 +16,9 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
color_dict
=
{
from
paddlehub.common.utils
import
is_windows
linux_color_dict
=
{
"white"
:
"
\033
[1;37m%s
\033
[0m"
,
"black"
:
"
\033
[30m%s
\033
[0m"
,
"dark_gray"
:
"
\033
[1;30m%s
\033
[0m"
,
...
...
@@ -35,8 +37,17 @@ color_dict = {
"yellow"
:
"
\033
[1;33m%s
\033
[0m"
}
windows_color_dict
=
{
key
:
"%s"
for
key
in
linux_color_dict
}
def
get_color_dict
():
if
is_windows
():
return
windows_color_dict
return
linux_color_dict
def
colorful_text
(
color
,
text
):
color_dict
=
get_color_dict
()
if
color
not
in
color_dict
:
color
=
color_dict
[
'blue'
]
else
:
...
...
@@ -44,6 +55,12 @@ def colorful_text(color, text):
return
color
%
text
def
get_ph_value
():
if
is_windows
():
return
0
return
11
class
TablePrinter
:
def
__init__
(
self
,
titles
,
...
...
@@ -76,7 +93,7 @@ class TablePrinter:
for
index
,
title
in
enumerate
(
self
.
titles
):
if
self
.
title_colors
[
index
]:
title
=
colorful_text
(
self
.
title_colors
[
index
],
title
)
_ph
=
11
_ph
=
get_ph_value
()
else
:
_ph
=
0
title_text
+=
(
"{0:%s%d}|"
%
...
...
@@ -108,7 +125,7 @@ class TablePrinter:
split_text
=
content
[
offset
[
index
]:
offset
[
index
]
+
length
]
if
colors
[
index
]
and
split_text
:
split_text
=
colorful_text
(
colors
[
index
],
split_text
)
_ph
=
11
_ph
=
get_ph_value
()
else
:
_ph
=
0
...
...
paddlehub/commands/list.py
浏览文件 @
7b4b4356
...
...
@@ -34,7 +34,12 @@ class ListCommand(BaseCommand):
def
exec
(
self
,
argv
):
all_modules
=
default_module_manager
.
all_modules
()
tp
=
TablePrinter
(
titles
=
[
"ModuleName"
,
"Path"
],
placeholders
=
[
25
,
50
])
if
utils
.
is_windows
():
placeholders
=
[
20
,
40
]
else
:
placeholders
=
[
25
,
50
]
tp
=
TablePrinter
(
titles
=
[
"ModuleName"
,
"Path"
],
placeholders
=
placeholders
)
for
module_name
,
module_dir
in
all_modules
.
items
():
tp
.
add_line
(
contents
=
[
module_name
,
module_dir
])
print
(
tp
.
get_text
())
...
...
paddlehub/commands/search.py
浏览文件 @
7b4b4356
...
...
@@ -44,9 +44,13 @@ class SearchCommand(BaseCommand):
resource_name
=
argv
[
0
]
resource_list
=
default_hub_server
.
search_resource
(
resource_name
)
if
utils
.
is_windows
():
placeholders
=
[
20
,
8
,
8
,
20
]
else
:
placeholders
=
[
30
,
8
,
8
,
25
]
tp
=
TablePrinter
(
titles
=
[
"ResourceName"
,
"Type"
,
"Version"
,
"Summary"
],
placeholders
=
[
30
,
8
,
8
,
25
]
)
placeholders
=
placeholders
)
for
resource_name
,
resource_type
,
resource_version
,
resource_summary
in
resource_list
:
if
resource_type
==
"Module"
:
colors
=
[
"yellow"
,
None
,
None
,
None
]
...
...
paddlehub/commands/show.py
浏览文件 @
7b4b4356
...
...
@@ -20,6 +20,7 @@ import os
import
argparse
from
paddlehub.common.logger
import
logger
from
paddlehub.common
import
utils
from
paddlehub.commands.base_command
import
BaseCommand
,
ENTRY
from
paddlehub.commands.cml_utils
import
TablePrinter
from
paddlehub.module.manager
import
default_module_manager
...
...
@@ -42,9 +43,13 @@ class ShowCommand(BaseCommand):
def
show_model_info
(
self
,
model_info_file
):
model_info
=
yaml_parser
.
parse
(
model_info_file
)
if
utils
.
is_windows
():
placeholders
=
[
15
,
40
]
else
:
placeholders
=
[
15
,
50
]
tp
=
TablePrinter
(
titles
=
[
"ModelName"
,
model_info
[
'name'
]],
placeholders
=
[
15
,
50
]
,
placeholders
=
placeholders
,
title_colors
=
[
"yellow"
,
None
],
title_aligns
=
[
"^"
,
"<"
])
tp
.
add_line
(
...
...
@@ -72,9 +77,13 @@ class ShowCommand(BaseCommand):
def
show_module_info
(
self
,
module_dir
):
module
=
Module
(
module_dir
=
module_dir
)
if
utils
.
is_windows
():
placeholders
=
[
15
,
40
]
else
:
placeholders
=
[
15
,
50
]
tp
=
TablePrinter
(
titles
=
[
"ModuleName"
,
module
.
name
],
placeholders
=
[
15
,
50
]
,
placeholders
=
placeholders
,
title_colors
=
[
"light_red"
,
None
],
title_aligns
=
[
"^"
,
"<"
])
tp
.
add_line
(
...
...
paddlehub/common/utils.py
浏览文件 @
7b4b4356
...
...
@@ -20,6 +20,7 @@ import os
import
time
import
multiprocessing
import
hashlib
import
platform
import
paddle
import
paddle.fluid
as
fluid
...
...
@@ -28,6 +29,14 @@ from paddlehub.module import module_desc_pb2
from
paddlehub.common.logger
import
logger
def
get_platform
():
return
platform
.
platform
()
def
is_windows
():
return
get_platform
().
lower
().
startswith
(
"windows"
)
def
to_list
(
input
):
if
not
isinstance
(
input
,
list
):
if
not
isinstance
(
input
,
tuple
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录