1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
"""
Verify that the PyPy source files have no tabs.
"""
import os
from pypy import pypydir
ROOT = os.path.abspath(os.path.join(pypydir, '..'))
RPYTHONDIR = os.path.join(ROOT, "rpython")
EXCLUDE = {'/virt_test'}
# ^^^ don't look inside this: it is created by virtualenv on buildslaves.
# It contains third-party installations that may include tabs in their
# .py files.
def test_no_tabs():
def walk(reldir):
if reldir in EXCLUDE:
return
if reldir:
path = os.path.join(ROOT, *reldir.split('/'))
else:
path = ROOT
if os.path.isfile(path):
if path.lower().endswith('.py'):
f = open(path, 'r')
data = f.read()
f.close()
assert '\t' not in data, "%r contains tabs!" % (reldir,)
elif os.path.isdir(path) and not os.path.islink(path):
for entry in os.listdir(path):
if not entry.startswith('.'):
walk('%s/%s' % (reldir, entry))
walk('')
def test_no_pypy_import_in_rpython():
def walk(reldir):
print reldir
if reldir:
path = os.path.join(RPYTHONDIR, *reldir.split('/'))
else:
path = RPYTHONDIR
if os.path.isfile(path):
if not path.lower().endswith('.py'):
return
with file(path) as f:
for line in f:
if "import" not in line:
continue
assert "from pypy." not in line
assert "import pypy." not in line
elif os.path.isdir(path) and not os.path.islink(path):
for entry in os.listdir(path):
if not entry.startswith('.'):
walk('%s/%s' % (reldir, entry))
walk('')
|