source: trunk/misc/coding_tools/check-umids.py

Last change on this file was b856238, checked in by Alexandre Detiste <alexandre.detiste@…>, at 2024-02-15T15:53:34Z

remove old Python2 future statements

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#! /usr/bin/python3
2
3"""
4Ensure UMIDS are unique.
5
6This runs on Python 3.
7"""
8
9# ./check-umids.py src
10
11
12import sys, re, os
13
14ok = True
15umids = {}
16
17for starting_point in sys.argv[1:]:
18    for root, dirs, files in os.walk(starting_point):
19        for fn in [f for f in files if f.endswith(".py")]:
20            fn = os.path.join(root, fn)
21            for lineno,line in enumerate(open(fn, "r").readlines()):
22                lineno = lineno+1
23                if "umid" not in line:
24                    continue
25                mo = re.search("umid=[\"\']([^\"\']+)[\"\']", line)
26                if mo:
27                    umid = mo.group(1)
28                    if umid in umids:
29                        oldfn, oldlineno = umids[umid]
30                        print("%s:%d: duplicate umid '%s'" % (fn, lineno, umid))
31                        print("%s:%d: first used here" % (oldfn, oldlineno))
32                        ok = False
33                    umids[umid] = (fn,lineno)
34
35if ok:
36    print("all umids are unique")
37else:
38    print("some umids were duplicates")
39    sys.exit(1)
Note: See TracBrowser for help on using the repository browser.