Also check for spelling errors in .asciidoc/.js files.
This commit is contained in:
parent
1672399252
commit
d845ecd7fc
@ -36,14 +36,20 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
|
|||||||
from scripts import utils
|
from scripts import utils
|
||||||
|
|
||||||
|
|
||||||
def _py_files():
|
def _get_files(only_py=False):
|
||||||
"""Iterate over all python files and yield filenames."""
|
"""Iterate over all python files and yield filenames."""
|
||||||
for (dirpath, _dirnames, filenames) in os.walk('.'):
|
for (dirpath, _dirnames, filenames) in os.walk('.'):
|
||||||
parts = dirpath.split(os.sep)
|
parts = dirpath.split(os.sep)
|
||||||
if len(parts) >= 2 and parts[1].startswith('.'):
|
if len(parts) >= 2 and parts[1].startswith('.'):
|
||||||
# ignore hidden dirs
|
# ignore hidden dirs
|
||||||
continue
|
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)
|
yield os.path.join(dirpath, name)
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +93,7 @@ def check_spelling():
|
|||||||
seen = collections.defaultdict(list)
|
seen = collections.defaultdict(list)
|
||||||
try:
|
try:
|
||||||
ok = True
|
ok = True
|
||||||
for fn in _py_files():
|
for fn in _get_files():
|
||||||
with tokenize.open(fn) as f:
|
with tokenize.open(fn) as f:
|
||||||
if fn == os.path.join('.', 'scripts', 'dev', 'misc_checks.py'):
|
if fn == os.path.join('.', 'scripts', 'dev', 'misc_checks.py'):
|
||||||
continue
|
continue
|
||||||
@ -108,7 +114,7 @@ def check_vcs_conflict():
|
|||||||
"""Check VCS conflict markers."""
|
"""Check VCS conflict markers."""
|
||||||
try:
|
try:
|
||||||
ok = True
|
ok = True
|
||||||
for fn in _py_files():
|
for fn in _get_files(only_py=True):
|
||||||
with tokenize.open(fn) as f:
|
with tokenize.open(fn) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if any(line.startswith(c * 7) for c in '<>=|'):
|
if any(line.startswith(c * 7) for c in '<>=|'):
|
||||||
|
Loading…
Reference in New Issue
Block a user