From cd360c847c8b35981330cb8cb3d58b55038bccf5 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Wed, 4 Aug 2010 00:17:13 -0700 Subject: [PATCH] check-umids: oops, forgot to add the tool --- misc/coding_tools/check-umids.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 misc/coding_tools/check-umids.py diff --git a/misc/coding_tools/check-umids.py b/misc/coding_tools/check-umids.py new file mode 100755 index 00000000..05e8825b --- /dev/null +++ b/misc/coding_tools/check-umids.py @@ -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) -- 2.45.2