Commit 15e6f7d6 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #527 from rntz/master

fix linter to allow comments after includes
parents 6fba2335 725661bb
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'^\#include \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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment