Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
6f150cf1
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6f150cf1
编写于
4月 07, 2021
作者:
S
storypku
提交者:
Liu Jiaming
4月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Scripts: use yapf for python formatting instead of autopep8
上级
952032d4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
21 deletion
+20
-21
scripts/apollo_format.sh
scripts/apollo_format.sh
+4
-4
scripts/yapf.sh
scripts/yapf.sh
+16
-17
未找到文件。
scripts/apollo_format.sh
浏览文件 @
6f150cf1
...
...
@@ -55,8 +55,8 @@ function run_buildifier() {
bash
"
${
TOP_DIR
}
/scripts/buildifier.sh"
"
$@
"
}
function
run_
autopep8
()
{
bash
"
${
TOP_DIR
}
/scripts/
autopep8
.sh"
"
$@
"
function
run_
yapf
()
{
bash
"
${
TOP_DIR
}
/scripts/
yapf
.sh"
"
$@
"
}
function
run_shfmt
()
{
...
...
@@ -73,7 +73,7 @@ function run_apollo_format() {
if
c_family_ext
"
${
arg
}
"
||
proto_ext
"
${
arg
}
"
;
then
run_clang_format
"
${
arg
}
"
elif
py_ext
"
${
arg
}
"
;
then
run_
autopep8
"
${
arg
}
"
run_
yapf
"
${
arg
}
"
elif
prettier_ext
"
${
arg
}
"
;
then
run_prettier
"
${
arg
}
"
elif
bazel_extended
"
${
arg
}
"
;
then
...
...
@@ -89,7 +89,7 @@ function run_apollo_format() {
run_clang_format
"
${
arg
}
"
fi
if
[
"
${
FORMAT_PYTHON
}
"
-eq
1
]
;
then
run_
autopep8
"
${
arg
}
"
run_
yapf
"
${
arg
}
"
fi
if
[
"
${
FORMAT_SHELL
}
"
-eq
1
]
;
then
run_shfmt
"
${
arg
}
"
...
...
scripts/
autopep8
.sh
→
scripts/
yapf
.sh
浏览文件 @
6f150cf1
#!/usr/bin/env bash
###############################################################################
# Copyright 202
0
The Apollo Authors. All Rights Reserved.
# Copyright 202
1
The Apollo Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
...
...
@@ -17,7 +17,7 @@
###############################################################################
# Usage:
#
autopep8.sh <path/to/src
/dir/or/files>
#
yapf.sh <path/to/python
/dir/or/files>
# Fail on error
set
-e
...
...
@@ -25,27 +25,26 @@ set -e
TOP_DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/.."
&&
pwd
-P
)
"
source
"
${
TOP_DIR
}
/scripts/apollo.bashrc"
AUTOPEP8_CMD
=
"autopep8"
function
check_autopep8
()
{
if
[
-z
"
$(
command
-v
autopep8
)
"
]
;
then
error
"Oops, autopep8 missing..."
error
"Please make sure autopep8 is installed and check your PATH"
\
function
check_yapf
()
{
if
[
-z
"
$(
command
-v
yapf
)
"
]
;
then
error
"Oops, yapf missing..."
error
"Please make sure yapf is installed and check your PATH"
\
"settings. For Debian/Ubuntu, you can run the following command:"
error
" sudo pip
install --upgrade --no-cache-dir autopep8
"
error
" sudo pip
3 install --upgrade --no-cache-dir yapf
"
exit
1
fi
}
function
autopep8_run
()
{
${
AUTOPEP8_CMD
}
-i
"
$@
"
function
yapf_run
()
{
# TODO(storypku): yapf has a '--recursive' option.
yapf
-i
--style
=
'{based_on_style: google}'
"
$@
"
}
function
run_
autopep8
()
{
function
run_
yapf
()
{
for
target
in
"
$@
"
;
do
if
[
-f
"
${
target
}
"
]
;
then
if
py_ext
"
${
target
}
"
;
then
autopep8
_run
"
${
target
}
"
yapf
_run
"
${
target
}
"
info
"Done formatting
${
target
}
"
else
warning
"Do nothing.
${
target
}
is not a Python file."
...
...
@@ -57,21 +56,21 @@ function run_autopep8() {
warning
"Do nothing. No Python files found under
${
target
}
."
continue
fi
autopep8
_run
${
srcs
}
yapf
_run
${
srcs
}
ok
"Done formatting Python files under
${
target
}
"
fi
done
}
function
main
()
{
check_
autopep8
check_
yapf
if
[
"$#"
-eq
0
]
;
then
error
"Usage:
$0
<path/to/dirs/or/files>"
error
"Usage:
$0
<path/to/
python/
dirs/or/files>"
exit
1
fi
run_
autopep8
"
$@
"
run_
yapf
"
$@
"
}
main
"
$@
"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录