make tox env for code-checks

This executes: check-debugging, check-interfaces, check-miscaptures,
find-trailing-spaces, check-umids, pyflakes.

Other changes:

* fix check-umids.py to take starting points. run it as `check-umids.py
  src` instead of `check-umids.py src/allmydata/*.py`
* check-debugging: rewrite in python to run from tox: tox doesn't like
  to run shell scripts.
* put check-interfaces.py last: it produces lots of warnings, but passes
  anyways. The others only produce significant output if they fail.
This commit is contained in:
Brian Warner
2016-04-06 13:57:41 -10:00
parent d641aef2a3
commit 36c57c74f4
5 changed files with 60 additions and 28 deletions

View File

@ -1,27 +1,29 @@
#! /usr/bin/python
# ./rumid.py foo.py
# ./check-umids.py src
import sys, re, os
ok = True
umids = {}
for fn in sys.argv[1:]:
fn = os.path.abspath(fn)
for lineno,line in enumerate(open(fn, "r").readlines()):
lineno = lineno+1
if "umid" not in line:
continue
mo = re.search("umid=[\"\']([^\"\']+)[\"\']", line)
if mo:
umid = mo.group(1)
if umid in umids:
oldfn, oldlineno = umids[umid]
print "%s:%d: duplicate umid '%s'" % (fn, lineno, umid)
print "%s:%d: first used here" % (oldfn, oldlineno)
ok = False
umids[umid] = (fn,lineno)
for starting_point in sys.argv[1:]:
for root, dirs, files in os.walk(starting_point):
for fn in [f for f in files if f.endswith(".py")]:
fn = os.path.join(root, fn)
for lineno,line in enumerate(open(fn, "r").readlines()):
lineno = lineno+1
if "umid" not in line:
continue
mo = re.search("umid=[\"\']([^\"\']+)[\"\']", line)
if mo:
umid = mo.group(1)
if umid in umids:
oldfn, oldlineno = umids[umid]
print "%s:%d: duplicate umid '%s'" % (fn, lineno, umid)
print "%s:%d: first used here" % (oldfn, oldlineno)
ok = False
umids[umid] = (fn,lineno)
if ok:
print "all umids are unique"