Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
f1eb008c
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看板
提交
f1eb008c
编写于
5月 08, 2012
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add hb-diff-colorize
Accepts --format=html now.
上级
9155e4ff
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
106 addition
and
64 deletion
+106
-64
test/shaping/Makefile.am
test/shaping/Makefile.am
+1
-0
test/shaping/hb-diff
test/shaping/hb-diff
+2
-2
test/shaping/hb-diff-colorize
test/shaping/hb-diff-colorize
+7
-0
test/shaping/hb_test_tools.py
test/shaping/hb_test_tools.py
+96
-62
未找到文件。
test/shaping/Makefile.am
浏览文件 @
f1eb008c
...
...
@@ -11,6 +11,7 @@ manifests:
EXTRA_DIST
+=
\
hb-diff
\
hb-diff-colorize
\
hb-diff-filter-failures
\
hb-manifest-read
\
hb-manifest-update
\
...
...
test/shaping/hb-diff
浏览文件 @
f1eb008c
...
...
@@ -3,8 +3,8 @@
from
hb_test_tools
import
*
import
sys
,
os
if
len
(
sys
.
argv
)
<
3
:
print
"usage: %s
file1 file2
..."
%
sys
.
argv
[
0
]
if
len
(
sys
.
argv
)
<
2
:
print
"usage: %s
FILES
..."
%
sys
.
argv
[
0
]
sys
.
exit
(
1
)
ZipDiffer
.
diff_files
(
FileHelpers
.
open_file_or_stdin
(
f
)
for
f
in
sys
.
argv
[
1
:])
test/shaping/hb-diff-colorize
0 → 100755
浏览文件 @
f1eb008c
#!/usr/bin/python
from
hb_test_tools
import
*
formatter
=
ColorFormatter
.
Auto
(
sys
.
argv
)
colorizer
=
DiffColorizer
(
formatter
=
formatter
)
UtilMains
.
process_multiple_files
(
FilterHelpers
.
filter_printer_function_no_newline
(
colorizer
.
colorize_diff
))
test/shaping/hb_test_tools.py
浏览文件 @
f1eb008c
#!/usr/bin/python
import
sys
,
os
,
re
,
difflib
,
unicodedata
,
errno
import
sys
,
os
,
re
,
difflib
,
unicodedata
,
errno
,
cgi
from
itertools
import
*
diff_symbols
=
"-+=*&^%$#@!~/"
diff_colors
=
[
'red'
,
'green'
,
'blue'
]
class
Colors
:
class
ColorFormatter
:
class
Null
:
red
=
''
green
=
''
end
=
''
@
staticmethod
def
start_color
(
c
):
return
''
@
staticmethod
def
end_color
():
return
''
@
staticmethod
def
escape
(
s
):
return
s
@
staticmethod
def
newline
():
return
'
\n
'
class
ANSI
:
red
=
'
\033
[41;37;1m'
green
=
'
\033
[42;37;1m'
end
=
'
\033
[m'
@
staticmethod
def
start_color
(
c
):
return
{
'red'
:
'
\033
[41;37;1m'
,
'green'
:
'
\033
[42;37;1m'
,
'blue'
:
'
\033
[44;37;1m'
,
}[
c
]
@
staticmethod
def
end_color
():
return
'
\033
[m'
@
staticmethod
def
escape
(
s
):
return
s
@
staticmethod
def
newline
():
return
'
\n
'
class
HTML
:
red
=
'<span style="color:red">'
green
=
'<span style="color:green">'
end
=
'</span>'
@
staticmethod
def
start_color
(
c
):
return
'<span style="background:%s">'
%
c
@
staticmethod
def
end_color
():
return
'</span>'
@
staticmethod
def
escape
(
s
):
return
cgi
.
escape
(
s
)
@
staticmethod
def
newline
():
return
'<br/>
\n
'
@
staticmethod
def
Auto
(
argv
=
[],
out
=
sys
.
stdout
):
if
os
.
isatty
(
out
.
fileno
()):
color
=
Colors
.
ANSI
else
:
color
=
Colors
.
Null
if
"--color"
in
argv
:
argv
.
remove
(
"--color"
)
color
=
Colors
.
ANSI
if
"--color=ansi"
in
argv
:
argv
.
remove
(
"--color=ansi"
)
color
=
Colors
.
ANSI
if
"--color=html"
in
argv
:
argv
.
remove
(
"--color=html"
)
color
=
Colors
.
HTML
if
"--no-color"
in
argv
:
argv
.
remove
(
"--no-color"
)
color
=
Colors
.
Null
return
color
@
staticmethod
def
Default
(
argv
=
[]):
return
Colors
.
ANSI
class
FancyDiffer
:
format
=
ColorFormatter
.
ANSI
if
"--format"
in
argv
:
argv
.
remove
(
"--format"
)
format
=
ColorFormatter
.
ANSI
if
"--format=ansi"
in
argv
:
argv
.
remove
(
"--format=ansi"
)
format
=
ColorFormatter
.
ANSI
if
"--format=html"
in
argv
:
argv
.
remove
(
"--format=html"
)
format
=
ColorFormatter
.
HTML
if
"--no-format"
in
argv
:
argv
.
remove
(
"--no-format"
)
format
=
ColorFormatter
.
Null
return
format
class
DiffColorizer
:
diff_regex
=
re
.
compile
(
'([a-za-z0-9_]*)([^a-za-z0-9_]?)'
)
@
staticmethod
def
diff_lines
(
l1
,
l2
,
colors
=
Colors
.
Null
):
# Easy without colors
if
colors
==
Colors
.
Null
:
if
l1
==
l2
:
return
[
' '
,
l1
]
return
[
'-'
,
l1
,
'+'
,
l2
]
def
__init__
(
self
,
formatter
,
colors
=
diff_colors
,
symbols
=
diff_symbols
):
self
.
formatter
=
formatter
self
.
colors
=
colors
self
.
symbols
=
symbols
ss
=
[
FancyDiffer
.
diff_regex
.
sub
(
r
'\1\n\2\n'
,
l
).
splitlines
(
True
)
for
l
in
(
l1
,
l2
)]
def
colorize_lines
(
self
,
lines
):
lines
=
(
l
if
l
else
''
for
l
in
lines
)
ss
=
[
self
.
diff_regex
.
sub
(
r
'\1\n\2\n'
,
l
).
splitlines
(
True
)
for
l
in
lines
]
oo
=
[
""
,
""
]
st
=
[
False
,
False
]
for
l
in
difflib
.
Differ
().
compare
(
*
ss
):
...
...
@@ -68,29 +84,47 @@ class FancyDiffer:
if
l
[
0
]
==
' '
:
for
i
in
range
(
2
):
if
st
[
i
]:
oo
[
i
]
+=
colors
.
end
oo
[
i
]
+=
self
.
formatter
.
end_color
()
st
[
i
]
=
False
oo
=
[
o
+
l
[
2
:]
for
o
in
oo
]
oo
=
[
o
+
self
.
formatter
.
escape
(
l
[
2
:])
for
o
in
oo
]
continue
if
l
[
0
]
==
'-'
:
if
not
st
[
0
]:
oo
[
0
]
+=
colors
.
red
st
[
0
]
=
True
oo
[
0
]
+=
l
[
2
:]
if
l
[
0
]
in
self
.
symbols
:
i
=
self
.
symbols
.
index
(
l
[
0
])
if
not
st
[
i
]:
oo
[
i
]
+=
self
.
formatter
.
start_color
(
self
.
colors
[
i
])
st
[
i
]
=
True
oo
[
i
]
+=
self
.
formatter
.
escape
(
l
[
2
:])
continue
if
l
[
0
]
==
'+'
:
if
not
st
[
1
]:
oo
[
1
]
+=
colors
.
green
st
[
1
]
=
True
oo
[
1
]
+=
l
[
2
:]
for
i
in
range
(
2
):
if
st
[
i
]:
oo
[
i
]
+=
colors
.
end
st
[
i
]
=
0
oo
[
i
]
+=
self
.
formatter
.
end_color
()
st
[
i
]
=
False
oo
=
[
o
.
replace
(
'
\n
'
,
''
)
for
o
in
oo
]
if
oo
[
0
]
==
oo
[
1
]:
return
[
' '
,
oo
[
0
],
'
\n
'
]
return
[
'-'
,
oo
[
0
],
'
\n
'
,
'+'
,
oo
[
1
],
'
\n
'
]
return
[
s1
+
s2
+
self
.
formatter
.
newline
()
for
(
s1
,
s2
)
in
zip
(
self
.
symbols
,
oo
)
if
s2
]
def
colorize_diff
(
self
,
f
):
lines
=
[
None
,
None
]
for
l
in
f
:
if
l
[
0
]
not
in
self
.
symbols
:
yield
self
.
formatter
.
escape
(
l
).
replace
(
'
\n
'
,
self
.
formatter
.
newline
())
continue
i
=
self
.
symbols
.
index
(
l
[
0
])
if
lines
[
i
]:
# Flush
for
line
in
self
.
colorize_lines
(
lines
):
yield
line
lines
=
[
None
,
None
]
lines
[
i
]
=
l
[
1
:]
if
(
all
(
lines
)):
# Flush
for
line
in
self
.
colorize_lines
(
lines
):
yield
line
lines
=
[
None
,
None
]
if
(
any
(
lines
)):
# Flush
for
line
in
self
.
colorize_lines
(
lines
):
yield
line
class
ZipDiffer
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录