Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
b2f8b96a
Commit
b2f8b96a
authored
May 23, 2019
by
eqy
Committed by
Tianqi Chen
May 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LINT] handle more file types in ASF header (#3235)
* Update add_asf_header.py * Update add_asf_header.py
parent
28e8eca1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
tests/lint/add_asf_header.py
+19
-0
No files found.
tests/lint/add_asf_header.py
View file @
b2f8b96a
...
@@ -117,6 +117,7 @@ header_groovystyle = """
...
@@ -117,6 +117,7 @@ header_groovystyle = """
"""
.
strip
()
"""
.
strip
()
FMT_MAP
=
{
FMT_MAP
=
{
"sh"
:
header_pystyle
,
"cc"
:
header_cstyle
,
"cc"
:
header_cstyle
,
"h"
:
header_cstyle
,
"h"
:
header_cstyle
,
"py"
:
header_pystyle
,
"py"
:
header_pystyle
,
...
@@ -128,6 +129,7 @@ FMT_MAP = {
...
@@ -128,6 +129,7 @@ FMT_MAP = {
"cmake"
:
header_pystyle
,
"cmake"
:
header_pystyle
,
"rst"
:
header_rststyle
,
"rst"
:
header_rststyle
,
"gradle"
:
header_groovystyle
,
"gradle"
:
header_groovystyle
,
"xml"
:
header_mdstyle
,
}
}
def
add_header
(
fname
,
header
):
def
add_header
(
fname
,
header
):
...
@@ -142,6 +144,21 @@ def add_header(fname, header):
...
@@ -142,6 +144,21 @@ def add_header(fname, header):
return
return
with
open
(
fname
,
"w"
)
as
outfile
:
with
open
(
fname
,
"w"
)
as
outfile
:
skipline
=
False
lines
=
orig
.
split
(
'
\n
'
)
ext
=
os
.
path
.
splitext
(
fname
)[
1
][
1
:]
if
ext
==
'sh'
and
lines
[
0
][:
2
]
==
'#!'
:
skipline
=
True
elif
ext
==
'xml'
and
lines
[
0
][:
2
]
==
'<?'
:
skipline
=
True
if
skipline
:
outfile
.
write
(
lines
[
0
]
+
"
\n
"
)
outfile
.
write
(
header
+
"
\n\n
"
)
outfile
.
write
(
"
\n
"
.
join
(
lines
[
1
:]))
outfile
.
write
(
header
+
"
\n\n
"
)
outfile
.
write
(
orig
)
else
:
outfile
.
write
(
header
+
"
\n\n
"
)
outfile
.
write
(
header
+
"
\n\n
"
)
outfile
.
write
(
orig
)
outfile
.
write
(
orig
)
print
(
"Add header to
%
s"
%
fname
)
print
(
"Add header to
%
s"
%
fname
)
...
@@ -160,6 +177,8 @@ def main(args):
...
@@ -160,6 +177,8 @@ def main(args):
suffix
=
fname
.
split
(
"."
)[
-
1
]
suffix
=
fname
.
split
(
"."
)[
-
1
]
if
suffix
in
FMT_MAP
:
if
suffix
in
FMT_MAP
:
add_header
(
fname
,
FMT_MAP
[
suffix
])
add_header
(
fname
,
FMT_MAP
[
suffix
])
elif
os
.
path
.
basename
(
fname
)
==
'gradle.properties'
:
add_header
(
fname
,
FMT_MAP
[
'h'
])
else
:
else
:
print
(
"Cannot handle
%
s ..."
%
fname
)
print
(
"Cannot handle
%
s ..."
%
fname
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment