Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fc5bbdf7
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fc5bbdf7
编写于
1月 22, 2015
作者:
K
Kevin Yap
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make `make tidy` Python scripts more idiomatic
Also makes errorck.py and tidy.py compatible with Python 3.
上级
d8d5e4d2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
32 deletion
+21
-32
src/etc/errorck.py
src/etc/errorck.py
+14
-25
src/etc/licenseck.py
src/etc/licenseck.py
+6
-6
src/etc/tidy.py
src/etc/tidy.py
+1
-1
未找到文件。
src/etc/errorck.py
浏览文件 @
fc5bbdf7
...
...
@@ -14,11 +14,10 @@
import
sys
,
os
,
re
src_dir
=
sys
.
argv
[
1
]
err
code_map
=
{
}
errcode_map
=
{}
err
or_re
=
re
.
compile
(
"(E\d\d\d\d)"
)
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
src_dir
):
if
"src/test"
in
dirpath
or
"src/llvm"
in
dirpath
:
# Short circuit for fast
continue
...
...
@@ -28,15 +27,12 @@ for (dirpath, dirnames, filenames) in os.walk(src_dir):
continue
path
=
os
.
path
.
join
(
dirpath
,
filename
)
line_num
=
1
with
open
(
path
,
'r'
)
as
f
:
for
line
in
f
:
p
=
re
.
compile
(
"(E\d\d\d\d)"
)
m
=
p
.
search
(
line
)
if
not
m
is
None
:
errcode
=
m
.
group
(
1
)
with
open
(
path
,
'r'
)
as
f
:
for
line_num
,
line
in
enumerate
(
f
,
start
=
1
):
match
=
error_re
.
search
(
line
)
if
match
:
errcode
=
match
.
group
(
1
)
new_record
=
[(
errcode
,
path
,
line_num
,
line
)]
existing
=
errcode_map
.
get
(
errcode
)
if
existing
is
not
None
:
...
...
@@ -45,26 +41,19 @@ for (dirpath, dirnames, filenames) in os.walk(src_dir):
else
:
errcode_map
[
errcode
]
=
new_record
line_num
+=
1
errors
=
False
all_errors
=
[]
for
errcode
in
errcode_map
:
entries
=
errcode_map
[
errcode
]
all_errors
+=
[
entries
[
0
][
0
]]
for
errcode
,
entries
in
errcode_map
.
items
():
all_errors
.
append
(
entries
[
0
][
0
])
if
len
(
entries
)
>
1
:
print
"error: duplicate error code "
+
errcode
print
(
"error: duplicate error code "
+
errcode
)
for
entry
in
entries
:
print
entry
[
1
]
+
": "
+
str
(
entry
[
2
])
print
entry
[
3
]
print
(
"{1}: {2}
\n
{3}"
.
format
(
*
entry
))
errors
=
True
print
str
(
len
(
errcode_map
))
+
" error codes"
all_errors
.
sort
()
all_errors
.
reverse
()
print
"highest error code: "
+
all_errors
[
0
]
print
(
"{0} error codes"
.
format
(
len
(
errcode_map
)))
print
(
"highest error code: "
+
max
(
all_errors
))
if
errors
:
sys
.
exit
(
1
)
src/etc/licenseck.py
浏览文件 @
fc5bbdf7
...
...
@@ -57,18 +57,18 @@ exceptions = [
def
check_license
(
name
,
contents
):
# Whitelist check
for
exception
in
exceptions
:
if
name
.
endswith
(
exception
):
return
True
if
any
(
name
.
endswith
(
e
)
for
e
in
exceptions
):
return
True
# Xfail check
firstlineish
=
contents
[:
100
]
if
firstlineish
.
find
(
"ignore-license"
)
!=
-
1
:
if
"ignore-license"
in
firstlineish
:
return
True
# License check
boilerplate
=
contents
[:
500
]
if
(
boilerplate
.
find
(
license1
)
==
-
1
or
boilerplate
.
find
(
license2
)
==
-
1
)
and
\
(
boilerplate
.
find
(
license3
)
==
-
1
or
boilerplate
.
find
(
license4
)
==
-
1
):
if
(
license1
not
in
boilerplate
or
license2
not
in
boilerplate
)
and
\
(
license3
not
in
boilerplate
or
license4
not
in
boilerplate
):
return
False
return
True
src/etc/tidy.py
浏览文件 @
fc5bbdf7
...
...
@@ -113,7 +113,7 @@ try:
if
current_name
!=
""
:
do_license_check
(
current_name
,
current_contents
)
except
UnicodeDecodeError
,
e
:
except
UnicodeDecodeError
as
e
:
report_err
(
"UTF-8 decoding error "
+
str
(
e
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录