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