mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-25 13:29:45 +00:00
check-umids: oops, forgot to add the tool
This commit is contained in:
parent
818089644a
commit
cd360c847c
30
misc/coding_tools/check-umids.py
Executable file
30
misc/coding_tools/check-umids.py
Executable file
@ -0,0 +1,30 @@
|
||||
#! /usr/bin/python
|
||||
|
||||
# ./rumid.py foo.py
|
||||
|
||||
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)
|
||||
|
||||
if ok:
|
||||
print "all umids are unique"
|
||||
else:
|
||||
print "some umids were duplicates"
|
||||
sys.exit(1)
|
Loading…
x
Reference in New Issue
Block a user