Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
bfcddd32
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bfcddd32
编写于
4月 06, 2015
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #93 from ebraminio/archpy3
Make hb_test_tools.py compatible with python 3
上级
ce01ad7c
363ceec3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
19 deletion
+25
-19
test/shaping/hb_test_tools.py
test/shaping/hb_test_tools.py
+25
-19
未找到文件。
test/shaping/hb_test_tools.py
浏览文件 @
bfcddd32
#!/usr/bin/python
from
__future__
import
print_function
import
sys
,
os
,
re
,
difflib
,
unicodedata
,
errno
,
cgi
from
itertools
import
*
diff_symbols
=
"-+=*&^%$#@!~/"
diff_colors
=
[
'red'
,
'green'
,
'blue'
]
if
sys
.
version_info
[
0
]
>=
3
:
unichr
=
chr
class
ColorFormatter
:
class
Null
:
...
...
@@ -142,7 +146,7 @@ class ZipDiffer:
sys
.
stdout
.
writelines
([
symbols
[
i
],
l
])
except
IOError
as
e
:
if
e
.
errno
!=
errno
.
EPIPE
:
print
>>
sys
.
stderr
,
"%s: %s: %s"
%
(
sys
.
argv
[
0
],
e
.
filename
,
e
.
strerro
r
)
print
(
"%s: %s: %s"
%
(
sys
.
argv
[
0
],
e
.
filename
,
e
.
strerror
),
file
=
sys
.
stder
r
)
sys
.
exit
(
1
)
...
...
@@ -215,7 +219,7 @@ class DiffSinks:
else
:
failed
+=
1
total
=
passed
+
failed
print
"%d out of %d tests passed. %d failed (%g%%)"
%
(
passed
,
total
,
failed
,
100.
*
failed
/
total
)
print
(
"%d out of %d tests passed. %d failed (%g%%)"
%
(
passed
,
total
,
failed
,
100.
*
failed
/
total
)
)
@
staticmethod
def
print_ngrams
(
f
,
ns
=
(
1
,
2
,
3
)):
...
...
@@ -240,7 +244,7 @@ class DiffSinks:
del
importantgrams
for
ngram
,
stats
in
allgrams
.
iteritems
():
print
"zscore: %9f failed: %6d passed: %6d ngram: <%s>"
%
(
stats
.
zscore
(
allstats
),
stats
.
failed
.
count
,
stats
.
passed
.
count
,
','
.
join
(
"U+%04X"
%
u
for
u
in
ngram
))
print
(
"zscore: %9f failed: %6d passed: %6d ngram: <%s>"
%
(
stats
.
zscore
(
allstats
),
stats
.
failed
.
count
,
stats
.
passed
.
count
,
','
.
join
(
"U+%04X"
%
u
for
u
in
ngram
)
))
...
...
@@ -310,7 +314,7 @@ class FilterHelpers:
def
filter_printer_function
(
filter_callback
):
def
printer
(
f
):
for
line
in
filter_callback
(
f
):
print
line
print
(
line
)
return
printer
@
staticmethod
...
...
@@ -344,7 +348,7 @@ class UtilMains:
def
process_multiple_files
(
callback
,
mnemonic
=
"FILE"
):
if
"--help"
in
sys
.
argv
:
print
"Usage: %s %s..."
%
(
sys
.
argv
[
0
],
mnemonic
)
print
(
"Usage: %s %s..."
%
(
sys
.
argv
[
0
],
mnemonic
)
)
sys
.
exit
(
1
)
try
:
...
...
@@ -353,14 +357,14 @@ class UtilMains:
callback
(
FileHelpers
.
open_file_or_stdin
(
s
))
except
IOError
as
e
:
if
e
.
errno
!=
errno
.
EPIPE
:
print
>>
sys
.
stderr
,
"%s: %s: %s"
%
(
sys
.
argv
[
0
],
e
.
filename
,
e
.
strerro
r
)
print
(
"%s: %s: %s"
%
(
sys
.
argv
[
0
],
e
.
filename
,
e
.
strerror
),
file
=
sys
.
stder
r
)
sys
.
exit
(
1
)
@
staticmethod
def
process_multiple_args
(
callback
,
mnemonic
):
if
len
(
sys
.
argv
)
==
1
or
"--help"
in
sys
.
argv
:
print
"Usage: %s %s..."
%
(
sys
.
argv
[
0
],
mnemonic
)
print
(
"Usage: %s %s..."
%
(
sys
.
argv
[
0
],
mnemonic
)
)
sys
.
exit
(
1
)
try
:
...
...
@@ -368,7 +372,7 @@ class UtilMains:
callback
(
s
)
except
IOError
as
e
:
if
e
.
errno
!=
errno
.
EPIPE
:
print
>>
sys
.
stderr
,
"%s: %s: %s"
%
(
sys
.
argv
[
0
],
e
.
filename
,
e
.
strerro
r
)
print
(
"%s: %s: %s"
%
(
sys
.
argv
[
0
],
e
.
filename
,
e
.
strerror
),
file
=
sys
.
stder
r
)
sys
.
exit
(
1
)
@
staticmethod
...
...
@@ -377,8 +381,8 @@ class UtilMains:
concat_separator
=
False
):
if
"--help"
in
sys
.
argv
:
print
"Usage:
\n
%s %s...
\n
or:
\n
%s
\n\n
When called with no arguments, input is read from standard input."
\
%
(
sys
.
argv
[
0
],
mnemonic
,
sys
.
argv
[
0
])
print
(
"Usage:
\n
%s %s...
\n
or:
\n
%s
\n\n
When called with no arguments, input is read from standard input."
\
%
(
sys
.
argv
[
0
],
mnemonic
,
sys
.
argv
[
0
])
)
sys
.
exit
(
1
)
try
:
...
...
@@ -389,15 +393,15 @@ class UtilMains:
break
if
line
[
-
1
]
==
'
\n
'
:
line
=
line
[:
-
1
]
print
callback
(
line
)
print
(
callback
(
line
)
)
else
:
args
=
sys
.
argv
[
1
:]
if
concat_separator
!=
False
:
args
=
[
concat_separator
.
join
(
args
)]
print
separator
.
join
(
callback
(
x
)
for
x
in
(
args
))
print
(
separator
.
join
(
callback
(
x
)
for
x
in
(
args
)
))
except
IOError
as
e
:
if
e
.
errno
!=
errno
.
EPIPE
:
print
>>
sys
.
stderr
,
"%s: %s: %s"
%
(
sys
.
argv
[
0
],
e
.
filename
,
e
.
strerro
r
)
print
(
"%s: %s: %s"
%
(
sys
.
argv
[
0
],
e
.
filename
,
e
.
strerror
),
file
=
sys
.
stder
r
)
sys
.
exit
(
1
)
...
...
@@ -415,7 +419,9 @@ class Unicode:
@
staticmethod
def
encode
(
s
):
return
u
''
.
join
(
unichr
(
x
)
for
x
in
Unicode
.
parse
(
s
)).
encode
(
'utf-8'
)
s
=
u
''
.
join
(
unichr
(
x
)
for
x
in
Unicode
.
parse
(
s
))
if
sys
.
version_info
[
0
]
==
2
:
s
=
s
.
encode
(
'utf-8'
)
return
s
shorthands
=
{
"ZERO WIDTH NON-JOINER"
:
"ZWNJ"
,
...
...
@@ -471,7 +477,7 @@ class Manifest:
if
not
os
.
path
.
exists
(
s
):
if
strict
:
print
>>
sys
.
stderr
,
"%s: %s does not exist"
%
(
sys
.
argv
[
0
],
s
)
print
(
"%s: %s does not exist"
%
(
sys
.
argv
[
0
],
s
),
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
return
...
...
@@ -487,7 +493,7 @@ class Manifest:
yield
p
except
IOError
:
if
strict
:
print
>>
sys
.
stderr
,
"%s: %s does not exist"
%
(
sys
.
argv
[
0
],
os
.
path
.
join
(
s
,
"MANIFEST"
)
)
print
(
"%s: %s does not exist"
%
(
sys
.
argv
[
0
],
os
.
path
.
join
(
s
,
"MANIFEST"
)),
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
return
else
:
...
...
@@ -506,12 +512,12 @@ class Manifest:
dirnames
.
sort
()
filenames
.
sort
()
ms
=
os
.
path
.
join
(
dirpath
,
"MANIFEST"
)
print
" GEN %s"
%
ms
print
(
" GEN %s"
%
ms
)
m
=
open
(
ms
,
"w"
)
for
f
in
filenames
:
print
>>
m
,
f
print
(
f
,
file
=
m
)
for
f
in
dirnames
:
print
>>
m
,
f
print
(
f
,
file
=
m
)
for
f
in
dirnames
:
Manifest
.
update_recursive
(
os
.
path
.
join
(
dirpath
,
f
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录