Revision | 29299 (tree) |
---|---|
Time | 2021-12-21 04:12:23 |
Author | stefankueng |
make scripts work with Python 3
@@ -63,7 +63,7 @@ | ||
63 | 63 | def onProcessFile(self, dirpath, file): |
64 | 64 | fullfile = os.path.join(dirpath, file) |
65 | 65 | if self.verbose > 1: |
66 | - print fullfile | |
66 | + print (fullfile) | |
67 | 67 | elif self.verbose > 0: |
68 | 68 | sys.stdout.write('.') |
69 | 69 | self.grepHIDD(fullfile) |
@@ -78,9 +78,9 @@ | ||
78 | 78 | ref = "%s:%s:%s" % (fileinput.filename(), |
79 | 79 | fileinput.lineno(), |
80 | 80 | m.span()[0]) |
81 | - hidd = unicode(m.groups()[0]) | |
81 | + hidd = str(m.groups()[0]) | |
82 | 82 | if self.verbose > 1: |
83 | - print "%s %s" % (ref, hidd) | |
83 | + print( "%s %s" % (ref, hidd)) | |
84 | 84 | HIDDs.setdefault(hidd, []).append(ref) |
85 | 85 | |
86 | 86 |
@@ -121,16 +121,16 @@ | ||
121 | 121 | # Report for this file |
122 | 122 | i = set(IDDs.keys()) - set(Ignores.keys()) |
123 | 123 | h = set(HIDDs.keys()) |
124 | - print "# IDD/HIDD cross check report for %s" % rcfile | |
125 | - print "# XML source tree in %s" % xmldir | |
126 | - print "# IDDs found in resource file and missing in XML files" | |
124 | + print ("# IDD/HIDD cross check report for %s" % rcfile) | |
125 | + print ("# XML source tree in %s" % xmldir) | |
126 | + print ("# IDDs found in resource file and missing in XML files") | |
127 | 127 | for idds in sorted(i - h): |
128 | - print "%s: IDD_%s" % (IDDs[idds][0], idds) | |
128 | + print ("%s: IDD_%s" % (IDDs[idds][0], idds)) | |
129 | 129 | |
130 | 130 | |
131 | - print "# HIDDs found in XML files but not defined in resource file" | |
131 | + print ("# HIDDs found in XML files but not defined in resource file") | |
132 | 132 | for hidds in sorted(h - i): |
133 | - print "%s: HIDD_%s" % (HIDDs[hidds][0], hidds) | |
133 | + print ("%s: HIDD_%s" % (HIDDs[hidds][0], hidds)) | |
134 | 134 | |
135 | 135 | |
136 | 136 |
@@ -142,14 +142,14 @@ | ||
142 | 142 | try: |
143 | 143 | xw = XMLFileWalker(xmldir) |
144 | 144 | xw.walk() |
145 | - except IOError, e: | |
146 | - print e | |
145 | + except IOError as e: | |
146 | + print (e) | |
147 | 147 | sys.exit(1) |
148 | 148 | |
149 | 149 | |
150 | 150 | def main(): |
151 | 151 | if len(sys.argv) < 3: |
152 | - print "Usage: xmldir rcfile [ ignorefile ]" | |
152 | + print ("Usage: xmldir rcfile [ ignorefile ]") | |
153 | 153 | sys.exit(0) |
154 | 154 | |
155 | 155 | xmldir = sys.argv[1] |
@@ -24,6 +24,8 @@ | ||
24 | 24 | # Exceptions |
25 | 25 | # |
26 | 26 | |
27 | +def cmp(a, b): | |
28 | + return (a > b) - (a < b) | |
27 | 29 | |
28 | 30 | class FileutilError(Exception): |
29 | 31 | ''' |
@@ -307,10 +309,10 @@ | ||
307 | 309 | ''' |
308 | 310 | |
309 | 311 | def onProcessDir(self, dirpath, dir): |
310 | - print "DIR: <%r> <%r>" % (dirpath, dir) | |
312 | + print ("DIR: <%r> <%r>" % (dirpath, dir)) | |
311 | 313 | |
312 | 314 | def onProcessFile(self, dirpath, file): |
313 | - print "FILE: <%r> <%r>" % (dirpath, file) | |
315 | + print ("FILE: <%r> <%r>" % (dirpath, file)) | |
314 | 316 | |
315 | 317 | # --------------------------------------------------------- |
316 | 318 | # Utility Functions |
@@ -330,7 +332,7 @@ | ||
330 | 332 | |
331 | 333 | def __test_walk(dirs): |
332 | 334 | for dir in dirs: |
333 | - print 'SimpleFileWalker(%r):' % (dir, ) | |
335 | + print ('SimpleFileWalker(%r):' % (dir, )) | |
334 | 336 | w = SimpleFileWalker(dir) |
335 | 337 | w.walk() |
336 | 338 |