Also check for spelling errors in .asciidoc/.js files.

This commit is contained in:
Florian Bruhin 2015-06-29 17:44:36 +02:00
parent 1672399252
commit d845ecd7fc

View File

@ -36,14 +36,20 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
from scripts import utils
def _py_files():
def _get_files(only_py=False):
"""Iterate over all python files and yield filenames."""
for (dirpath, _dirnames, filenames) in os.walk('.'):
parts = dirpath.split(os.sep)
if len(parts) >= 2 and parts[1].startswith('.'):
# ignore hidden dirs
continue
for name in (e for e in filenames if e.endswith('.py')):
if only_py:
endings = {'.py'}
else:
endings = {'.py', '.asciidoc', '.js'}
files = (e for e in filenames if os.path.splitext(e)[1] in endings)
for name in files:
yield os.path.join(dirpath, name)
@ -87,7 +93,7 @@ def check_spelling():
seen = collections.defaultdict(list)
try:
ok = True
for fn in _py_files():
for fn in _get_files():
with tokenize.open(fn) as f:
if fn == os.path.join('.', 'scripts', 'dev', 'misc_checks.py'):
continue
@ -108,7 +114,7 @@ def check_vcs_conflict():
"""Check VCS conflict markers."""
try:
ok = True
for fn in _py_files():
for fn in _get_files(only_py=True):
with tokenize.open(fn) as f:
for line in f:
if any(line.startswith(c * 7) for c in '<>=|'):