Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
15e6f7d6
Commit
15e6f7d6
authored
May 19, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #527 from rntz/master
fix linter to allow comments after includes
parents
6fba2335
725661bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
tools/lint.py
tools/lint.py
+8
-4
No files found.
tools/lint.py
View file @
15e6f7d6
import
os
import
os
import
sys
import
sys
import
re
def
file_is_from_cpython
(
fn
):
def
file_is_from_cpython
(
fn
):
if
'from_cpython'
in
fn
:
if
'from_cpython'
in
fn
:
...
@@ -49,6 +50,8 @@ PYSTON_SRC_SUBDIRS = [bn for bn in os.listdir(PYSTON_SRC_DIR) if os.path.isdir(o
...
@@ -49,6 +50,8 @@ PYSTON_SRC_SUBDIRS = [bn for bn in os.listdir(PYSTON_SRC_DIR) if os.path.isdir(o
CAPI_HEADER_DIR
=
os
.
path
.
join
(
PYSTON_SRC_DIR
,
"../from_cpython/Include"
)
CAPI_HEADER_DIR
=
os
.
path
.
join
(
PYSTON_SRC_DIR
,
"../from_cpython/Include"
)
CAPI_HEADERS
=
[
bn
for
bn
in
os
.
listdir
(
CAPI_HEADER_DIR
)
if
bn
.
endswith
(
".h"
)]
CAPI_HEADERS
=
[
bn
for
bn
in
os
.
listdir
(
CAPI_HEADER_DIR
)
if
bn
.
endswith
(
".h"
)]
include_re
=
re
.
compile
(
r'^\
#i
nclude \
s+ (<.+?>|
".+?") (?:\
s+ //.*)? $
', re.VERBOSE)
def verify_include_order(_, dir, files):
def verify_include_order(_, dir, files):
for bn in files:
for bn in files:
fn = os.path.join(dir, bn)
fn = os.path.join(dir, bn)
...
@@ -71,10 +74,11 @@ def verify_include_order(_, dir, files):
...
@@ -71,10 +74,11 @@ def verify_include_order(_, dir, files):
section = None
section = None
continue
continue
if
l
.
startswith
(
"#include"
):
m = include_re.match(l)
if m:
if section is None:
if section is None:
section = []
section = []
section
.
append
(
l
)
section.append(
m.group(1)
)
continue
continue
if l.startswith("#ifndef PYSTON") or l.startswith("#define PYSTON"):
if l.startswith("#ifndef PYSTON") or l.startswith("#define PYSTON"):
...
@@ -99,7 +103,7 @@ def verify_include_order(_, dir, files):
...
@@ -99,7 +103,7 @@ def verify_include_order(_, dir, files):
def is_third_party_section(section):
def is_third_party_section(section):
for incl in section:
for incl in section:
if
incl
.
startswith
(
'
#include
"llvm/'
):
if incl.startswith('"llvm/'):
continue
continue
if '"
opagent
.
h
"' in incl:
if '"
opagent
.
h
"' in incl:
continue
continue
...
@@ -119,7 +123,7 @@ def verify_include_order(_, dir, files):
...
@@ -119,7 +123,7 @@ def verify_include_order(_, dir, files):
# TODO generate this
# TODO generate this
include_dirs = PYSTON_SRC_SUBDIRS
include_dirs = PYSTON_SRC_SUBDIRS
for incl in section:
for incl in section:
if
not
any
(
incl
.
startswith
(
'
#include
"%s/'
%
d
)
for
d
in
include_dirs
):
if not any(incl.startswith('"
%
s
/
' % d) for d in include_dirs):
return False
return False
return True
return True
...
...
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