diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2013-09-22 17:08:12 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2013-09-22 17:08:12 (GMT) |
commit | 953dc41b8b720fdcec7955de67d23206214e5125 (patch) | |
tree | b95b2144ccf82d8227cec025af152f4eadfa7282 /bin | |
parent | 328e541f40849c270fc75f0932594d18d2e6340b (diff) | |
download | SCons-953dc41b8b720fdcec7955de67d23206214e5125.zip SCons-953dc41b8b720fdcec7955de67d23206214e5125.tar.gz SCons-953dc41b8b720fdcec7955de67d23206214e5125.tar.bz2 |
Result of raw 2to3 run (2to3-2.7); checkpoint for python3 conversion.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/Command.py | 6 | ||||
-rw-r--r-- | bin/SConsDoc.py | 28 | ||||
-rw-r--r-- | bin/SConsExamples.py | 20 | ||||
-rw-r--r-- | bin/calibrate.py | 8 | ||||
-rw-r--r-- | bin/caller-tree.py | 10 | ||||
-rw-r--r-- | bin/docs-create-example-outputs.py | 6 | ||||
-rw-r--r-- | bin/docs-update-generated.py | 2 | ||||
-rw-r--r-- | bin/docs-validate.py | 8 | ||||
-rw-r--r-- | bin/install_python.py | 6 | ||||
-rw-r--r-- | bin/install_scons.py | 10 | ||||
-rw-r--r-- | bin/linecount.py | 30 | ||||
-rw-r--r-- | bin/memlogs.py | 8 | ||||
-rw-r--r-- | bin/memoicmp.py | 24 | ||||
-rw-r--r-- | bin/objcounts.py | 13 | ||||
-rw-r--r-- | bin/scons-diff.py | 14 | ||||
-rw-r--r-- | bin/scons-proc.py | 14 | ||||
-rw-r--r-- | bin/scons-test.py | 60 | ||||
-rw-r--r-- | bin/scons-unzip.py | 2 | ||||
-rw-r--r-- | bin/scons_dev_master.py | 6 | ||||
-rwxr-xr-x | bin/svn-bisect.py | 14 | ||||
-rw-r--r-- | bin/update-release-info.py | 30 | ||||
-rwxr-xr-x | bin/xmlagenda.py | 2 |
22 files changed, 160 insertions, 161 deletions
diff --git a/bin/Command.py b/bin/Command.py index 8702f51..768caed 100644 --- a/bin/Command.py +++ b/bin/Command.py @@ -109,18 +109,18 @@ Usage: script-template.py [-hnq] try: try: opts, args = getopt.getopt(argv[1:], short_options, long_options) - except getopt.error, msg: + except getopt.error as msg: raise Usage(msg) for o, a in opts: if o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-n', '--no-exec'): Command.execute = Command.do_not_execute elif o in ('-q', '--quiet'): Command.display = Command.do_not_display - except Usage, err: + except Usage as err: sys.stderr.write(err.msg) sys.stderr.write('use -h to get help') return 2 diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index dc9d161..453e241 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -210,12 +210,12 @@ class Libxml2ValidityHandler: def error(self, msg, data): if data != ARG: - raise Exception, "Error handler did not receive correct argument" + raise Exception("Error handler did not receive correct argument") self.errors.append(msg) def warning(self, msg, data): if data != ARG: - raise Exception, "Warning handler did not receive correct argument" + raise Exception("Warning handler did not receive correct argument") self.warnings.append(msg) @@ -332,16 +332,16 @@ if not has_libxml2: xmlschema = etree.XMLSchema(xmlschema_context) try: doc = etree.parse(fpath) - except Exception, e: - print "ERROR: %s fails to parse:"%fpath - print e + except Exception as e: + print("ERROR: %s fails to parse:"%fpath) + print(e) return False doc.xinclude() try: xmlschema.assertValid(doc) - except Exception, e: - print "ERROR: %s fails to validate:" % fpath - print e + except Exception as e: + print("ERROR: %s fails to validate:" % fpath) + print(e) return False return True @@ -477,8 +477,8 @@ else: if err or eh.errors: for e in eh.errors: - print e.rstrip("\n") - print "%s fails to validate" % fpath + print(e.rstrip("\n")) + print("%s fails to validate" % fpath) return False return True @@ -599,7 +599,7 @@ class SConsDocTree: # Create xpath context self.xpath_context = self.doc.xpathNewContext() # Register namespaces - for key, val in self.nsmap.iteritems(): + for key, val in self.nsmap.items(): self.xpath_context.xpathRegisterNs(key, val) def __del__(self): @@ -637,8 +637,8 @@ def validate_all_xml(dpaths, xsdfile=default_xsd): fails = [] for idx, fp in enumerate(fpaths): fpath = os.path.join(path, fp) - print "%.2f%s (%d/%d) %s" % (float(idx+1)*100.0/float(len(fpaths)), - perc, idx+1, len(fpaths),fp) + print("%.2f%s (%d/%d) %s" % (float(idx+1)*100.0/float(len(fpaths)), + perc, idx+1, len(fpaths),fp)) if not tf.validateXml(fp, xmlschema_context): fails.append(fp) @@ -810,7 +810,7 @@ def importfile(path): file = open(path, 'r') try: module = imp.load_module(name, file, path, (ext, 'r', kind)) - except ImportError, e: + except ImportError as e: sys.stderr.write("Could not import %s: %s\n" % (path, e)) return None file.close() diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py index 9823a05..e3a7502 100644 --- a/bin/SConsExamples.py +++ b/bin/SConsExamples.py @@ -265,7 +265,7 @@ def ensureExampleOutputsExist(dpath): os.mkdir(generated_examples) examples = readAllExampleInfos(dpath) - for key, value in examples.iteritems(): + for key, value in examples.items(): # Process all scons_output tags for o in value.outputs: cpath = os.path.join(generated_examples, @@ -303,10 +303,10 @@ def createAllExampleOutputs(dpath): examples = readAllExampleInfos(dpath) total = len(examples) idx = 0 - for key, value in examples.iteritems(): + for key, value in examples.items(): # Process all scons_output tags - print "%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total), - perc, idx + 1, total, key) + print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total), + perc, idx + 1, total, key)) create_scons_output(value) # Process all scons_example_file tags @@ -344,7 +344,7 @@ def collectSConsExampleNames(fpath): if n not in suffixes: suffixes[n] = [] else: - print "Error: Example in file '%s' is missing a name!" % fpath + print("Error: Example in file '%s' is missing a name!" % fpath) failed_suffixes = True for o in stf.findAll(t.root, "scons_output", SConsDoc.dbxid, @@ -353,11 +353,11 @@ def collectSConsExampleNames(fpath): if stf.hasAttribute(o, 'example'): n = stf.getAttribute(o, 'example') else: - print "Error: scons_output in file '%s' is missing an example name!" % fpath + print("Error: scons_output in file '%s' is missing an example name!" % fpath) failed_suffixes = True if n not in suffixes: - print "Error: scons_output in file '%s' is referencing non-existent example '%s'!" % (fpath, n) + print("Error: scons_output in file '%s' is referencing non-existent example '%s'!" % (fpath, n)) failed_suffixes = True continue @@ -365,13 +365,13 @@ def collectSConsExampleNames(fpath): if stf.hasAttribute(o, 'suffix'): s = stf.getAttribute(o, 'suffix') else: - print "Error: scons_output in file '%s' (example '%s') is missing a suffix!" % (fpath, n) + print("Error: scons_output in file '%s' (example '%s') is missing a suffix!" % (fpath, n)) failed_suffixes = True if s not in suffixes[n]: suffixes[n].append(s) else: - print "Error: scons_output in file '%s' (example '%s') is using a duplicate suffix '%s'!" % (fpath, n, s) + print("Error: scons_output in file '%s' (example '%s') is using a duplicate suffix '%s'!" % (fpath, n, s)) failed_suffixes = True return names, failed_suffixes @@ -392,7 +392,7 @@ def exampleNamesAreUnique(dpath): unique = False i = allnames.intersection(names) if i: - print "Not unique in %s are: %s" % (fpath, ', '.join(i)) + print("Not unique in %s are: %s" % (fpath, ', '.join(i))) unique = False allnames |= names diff --git a/bin/calibrate.py b/bin/calibrate.py index 8ed2ece..31c04e8 100644 --- a/bin/calibrate.py +++ b/bin/calibrate.py @@ -20,7 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import division + import optparse import os @@ -48,7 +48,7 @@ def main(argv=None): for arg in args: if len(args) > 1: - print arg + ':' + print(arg + ':') command = [sys.executable, 'runtest.py'] if opts.package: @@ -67,9 +67,9 @@ def main(argv=None): try: elapsed = float(em.group(1)) except AttributeError: - print output + print(output) raise - print "run %3d: %7.3f: %s" % (run, elapsed, ' '.join(vm.groups())) + print("run %3d: %7.3f: %s" % (run, elapsed, ' '.join(vm.groups()))) if opts.min < elapsed and elapsed < opts.max: good += 1 else: diff --git a/bin/caller-tree.py b/bin/caller-tree.py index 03c1616..327e6a1 100644 --- a/bin/caller-tree.py +++ b/bin/caller-tree.py @@ -74,19 +74,19 @@ for line in sys.stdin.readlines(): stack = [] def print_entry(e, level, calls): - print '%-72s%6s' % ((' '*2*level) + e.file_line_func, calls) + print('%-72s%6s' % ((' '*2*level) + e.file_line_func, calls)) if e in stack: - print (' '*2*(level+1))+'RECURSION' - print + print((' '*2*(level+1))+'RECURSION') + print() elif e.called_by: stack.append(e) for c in e.called_by: print_entry(c[0], level+1, c[1]) stack.pop() else: - print + print() -for e in [ e for e in AllCalls.values() if not e.calls ]: +for e in [ e for e in list(AllCalls.values()) if not e.calls ]: print_entry(e, 0, '') # Local Variables: diff --git a/bin/docs-create-example-outputs.py b/bin/docs-create-example-outputs.py index 30dc0ee..b2dfbea 100644 --- a/bin/docs-create-example-outputs.py +++ b/bin/docs-create-example-outputs.py @@ -9,11 +9,11 @@ import sys import SConsExamples if __name__ == "__main__": - print "Checking whether all example names are unique..." + print("Checking whether all example names are unique...") if SConsExamples.exampleNamesAreUnique(os.path.join('doc','user')): - print "OK" + print("OK") else: - print "Not all example names and suffixes are unique! Please correct the errors listed above and try again." + print("Not all example names and suffixes are unique! Please correct the errors listed above and try again.") sys.exit(0) SConsExamples.createAllExampleOutputs(os.path.join('doc','user')) diff --git a/bin/docs-update-generated.py b/bin/docs-update-generated.py index 66b22c0..2b419a4 100644 --- a/bin/docs-update-generated.py +++ b/bin/docs-update-generated.py @@ -38,7 +38,7 @@ def generate_all(): try: os.makedirs(gen_folder) except: - print "Couldn't create destination folder %s! Exiting..." % gen_folder + print("Couldn't create destination folder %s! Exiting..." % gen_folder) return # Call scons-proc.py os.system('python %s -b %s -f %s -t %s -v %s %s' % diff --git a/bin/docs-validate.py b/bin/docs-validate.py index c445c3f..e5d0659 100644 --- a/bin/docs-validate.py +++ b/bin/docs-validate.py @@ -10,9 +10,9 @@ import SConsDoc if __name__ == "__main__": if len(sys.argv)>1: if SConsDoc.validate_all_xml((sys.argv[1],)): - print "OK" + print("OK") else: - print "Validation failed! Please correct the errors above and try again." + print("Validation failed! Please correct the errors above and try again.") else: if SConsDoc.validate_all_xml(['src', os.path.join('doc','design'), @@ -22,6 +22,6 @@ if __name__ == "__main__": os.path.join('doc','reference'), os.path.join('doc','user') ]): - print "OK" + print("OK") else: - print "Validation failed! Please correct the errors above and try again." + print("Validation failed! Please correct the errors above and try again.") diff --git a/bin/install_python.py b/bin/install_python.py index 86807af..dca37d0 100644 --- a/bin/install_python.py +++ b/bin/install_python.py @@ -48,7 +48,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] try: try: opts, args = getopt.getopt(argv[1:], short_options, long_options) - except getopt.error, msg: + except getopt.error as msg: raise Usage(msg) for o, a in opts: @@ -57,7 +57,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] elif o in ('-d', '--downloads'): downloads_dir = a elif o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-n', '--no-exec'): CommandRunner.execute = CommandRunner.do_not_execute @@ -65,7 +65,7 @@ Usage: install_python.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] prefix = a elif o in ('-q', '--quiet'): CommandRunner.display = CommandRunner.do_not_display - except Usage, err: + except Usage as err: sys.stderr.write(str(err.msg) + '\n') sys.stderr.write('use -h to get help\n') return 2 diff --git a/bin/install_scons.py b/bin/install_scons.py index 00129f6..b732193 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -23,7 +23,7 @@ import os import shutil import sys import tarfile -import urllib +import urllib.request, urllib.parse, urllib.error from Command import CommandRunner, Usage @@ -129,7 +129,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] try: try: opts, args = getopt.getopt(argv[1:], short_options, long_options) - except getopt.error, msg: + except getopt.error as msg: raise Usage(msg) for o, a in opts: @@ -138,7 +138,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] elif o in ('-d', '--downloads'): downloads_dir = a elif o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-n', '--no-exec'): CommandRunner.execute = CommandRunner.do_not_execute @@ -146,7 +146,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] prefix = a elif o in ('-q', '--quiet'): CommandRunner.display = CommandRunner.do_not_display - except Usage, err: + except Usage as err: sys.stderr.write(str(err.msg) + '\n') sys.stderr.write('use -h to get help\n') return 2 @@ -171,7 +171,7 @@ Usage: install_scons.py [-ahnq] [-d DIR] [-p PREFIX] [VERSION ...] if not os.path.exists(tar_gz): if not os.path.exists(downloads_dir): cmd.run('mkdir %(downloads_dir)s') - cmd.run((urllib.urlretrieve, tar_gz_url, tar_gz), + cmd.run((urllib.request.urlretrieve, tar_gz_url, tar_gz), 'wget -O %(tar_gz)s %(tar_gz_url)s') def extract(tar_gz): diff --git a/bin/linecount.py b/bin/linecount.py index 6f49dca..2d478f0 100644 --- a/bin/linecount.py +++ b/bin/linecount.py @@ -21,7 +21,7 @@ # in each category, the number of non-blank lines, and the number of # non-comment lines. The last figure (non-comment) lines is the most # interesting one for most purposes. -from __future__ import division + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -98,23 +98,23 @@ all_tests = Collection('all tests', src_tests.files + test_tests.files) def ratio(over, under): return "%.2f" % (float(len(over)) / float(len(under))) -print fmt % ('', '', '', '', '', 'non-blank') -print fmt % ('', 'files', 'lines', 'non-blank', 'non-comment', 'non-comment') -print -print fmt % src_Tests_py_tests.printables() -print fmt % src_test_tests.printables() -print -print fmt % src_tests.printables() -print fmt % test_tests.printables() -print -print fmt % all_tests.printables() -print fmt % sources.printables() -print -print fmt % ('ratio:', +print(fmt % ('', '', '', '', '', 'non-blank')) +print(fmt % ('', 'files', 'lines', 'non-blank', 'non-comment', 'non-comment')) +print() +print(fmt % src_Tests_py_tests.printables()) +print(fmt % src_test_tests.printables()) +print() +print(fmt % src_tests.printables()) +print(fmt % test_tests.printables()) +print() +print(fmt % all_tests.printables()) +print(fmt % sources.printables()) +print() +print(fmt % ('ratio:', ratio(all_tests, sources), ratio(all_tests.lines(), sources.lines()), ratio(all_tests.non_blank(), sources.non_blank()), ratio(all_tests.non_comment(), sources.non_comment()), ratio(all_tests.non_blank_non_comment(), sources.non_blank_non_comment()) - ) + )) diff --git a/bin/memlogs.py b/bin/memlogs.py index 9d957c9..0409dfe 100644 --- a/bin/memlogs.py +++ b/bin/memlogs.py @@ -27,20 +27,20 @@ import sys filenames = sys.argv[1:] if not filenames: - print """Usage: memlogs.py file [...] + print("""Usage: memlogs.py file [...] Summarizes the --debug=memory numbers from one or more build logs. -""" +""") sys.exit(0) fmt = "%12s %12s %12s %12s %s" -print fmt % ("pre-read", "post-read", "pre-build", "post-build", "") +print(fmt % ("pre-read", "post-read", "pre-build", "post-build", "")) for fname in sys.argv[1:]: lines = [l for l in open(fname).readlines() if l[:7] == 'Memory '] t = tuple([l.split()[-1] for l in lines]) + (fname,) - print fmt % t + print(fmt % t) # Local Variables: # tab-width:4 diff --git a/bin/memoicmp.py b/bin/memoicmp.py index 812af66..5021c41 100644 --- a/bin/memoicmp.py +++ b/bin/memoicmp.py @@ -23,20 +23,20 @@ def memoize_cmp(filea, fileb): ma = memoize_output(filea) mb = memoize_output(fileb) - print 'All output: %s / %s [delta]'%(filea, fileb) - print '----------HITS---------- ---------MISSES---------' + print('All output: %s / %s [delta]'%(filea, fileb)) + print('----------HITS---------- ---------MISSES---------') cfmt='%7d/%-7d [%d]' ma_o = [] mb_o = [] mab = [] - for k in ma.keys(): - if k in mb.keys(): + for k in list(ma.keys()): + if k in list(mb.keys()): if k not in mab: mab.append(k) else: ma_o.append(k) - for k in mb.keys(): - if k in ma.keys(): + for k in list(mb.keys()): + if k in list(ma.keys()): if k not in mab: mab.append(k) else: @@ -49,26 +49,26 @@ def memoize_cmp(filea, fileb): for k in mab: hits = cfmt%(ma[k][0], mb[k][0], mb[k][0]-ma[k][0]) miss = cfmt%(ma[k][1], mb[k][1], mb[k][1]-ma[k][1]) - print '%-24s %-24s %s'%(hits, miss, k) + print('%-24s %-24s %s'%(hits, miss, k)) for k in ma_o: hits = '%7d/ --'%(ma[k][0]) miss = '%7d/ --'%(ma[k][1]) - print '%-24s %-24s %s'%(hits, miss, k) + print('%-24s %-24s %s'%(hits, miss, k)) for k in mb_o: hits = ' -- /%-7d'%(mb[k][0]) miss = ' -- /%-7d'%(mb[k][1]) - print '%-24s %-24s %s'%(hits, miss, k) + print('%-24s %-24s %s'%(hits, miss, k)) - print '-'*(24+24+1+20) + print('-'*(24+24+1+20)) if __name__ == "__main__": if len(sys.argv) != 3: - print """Usage: %s file1 file2 + print("""Usage: %s file1 file2 -Compares --debug=memomize output from file1 against file2."""%sys.argv[0] +Compares --debug=memomize output from file1 against file2."""%sys.argv[0]) sys.exit(1) memoize_cmp(sys.argv[1], sys.argv[2]) diff --git a/bin/objcounts.py b/bin/objcounts.py index 0662012..25b985b 100644 --- a/bin/objcounts.py +++ b/bin/objcounts.py @@ -27,10 +27,10 @@ import sys filenames = sys.argv[1:] if len(sys.argv) != 3: - print """Usage: objcounts.py file1 file2 + print("""Usage: objcounts.py file1 file2 Compare the --debug=object counts from two build logs. -""" +""") sys.exit(0) def fetch_counts(fname): @@ -47,7 +47,7 @@ c1 = fetch_counts(sys.argv[1]) c2 = fetch_counts(sys.argv[2]) common = {} -for k in c1.keys(): +for k in list(c1.keys()): try: common[k] = (c1[k], c2[k]) except KeyError: @@ -58,7 +58,7 @@ for k in c1.keys(): if not '.' in k: s = '.'+k l = len(s) - for k2 in c2.keys(): + for k2 in list(c2.keys()): if k2[-l:] == s: common[k2] = (c1[k], c2[k2]) del c1[k] @@ -81,10 +81,9 @@ def diffstr(c1, c2): return " %5s/%-5s %-8s" % (c1, c2, d) def printline(c1, c2, classname): - print \ - diffstr(c1[2], c2[2]) + \ + print(diffstr(c1[2], c2[2]) + \ diffstr(c1[3], c2[3]) + \ - ' ' + classname + ' ' + classname) for k in sorted(common.keys()): c = common[k] diff --git a/bin/scons-diff.py b/bin/scons-diff.py index 52bd51b..5181fa1 100644 --- a/bin/scons-diff.py +++ b/bin/scons-diff.py @@ -43,7 +43,7 @@ def diff_line(left, right): opts = ' ' + ' '.join(diff_options) else: opts = '' - print 'diff%s %s %s' % (opts, left, right) + print('diff%s %s %s' % (opts, left, right)) for o, a in opts: if o in ('-c', '-u'): @@ -51,7 +51,7 @@ for o, a in opts: context = int(a) diff_options.append(o) elif o in ('-h', '--help'): - print Usage + print(Usage) sys.exit(0) elif o in ('-n'): diff_options.append(o) @@ -161,9 +161,9 @@ def diff_file(left, right): else: if text: diff_line(left, right) - print text, + print(text, end=' ') elif report_same: - print 'Files %s and %s are identical' % (left, right) + print('Files %s and %s are identical' % (left, right)) def diff_dir(left, right): llist = os.listdir(left) @@ -173,16 +173,16 @@ def diff_dir(left, right): u[l] = 1 for r in rlist: u[r] = 1 - for x in sorted([ x for x in u.keys() if x[-4:] != '.pyc' ]): + for x in sorted([ x for x in list(u.keys()) if x[-4:] != '.pyc' ]): if x in llist: if x in rlist: do_diff(os.path.join(left, x), os.path.join(right, x), recursive) else: - print 'Only in %s: %s' % (left, x) + print('Only in %s: %s' % (left, x)) else: - print 'Only in %s: %s' % (right, x) + print('Only in %s: %s' % (right, x)) do_diff(left, right, True) diff --git a/bin/scons-proc.py b/bin/scons-proc.py index 9567db8..19be4c3 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -106,7 +106,7 @@ Link_Entities_Header = """\ class SCons_XML(object): def __init__(self, entries, **kw): self.values = entries - for k, v in kw.items(): + for k, v in list(kw.items()): setattr(self, k, v) def fopen(self, name): @@ -344,25 +344,25 @@ def write_output_files(h, buildersfiles, functionsfiles, processor_class = SCons_XML # Step 1: Creating entity files for builders, functions,... -print "Generating entity files..." +print("Generating entity files...") h = parse_docs(args, False) write_output_files(h, buildersfiles, functionsfiles, toolsfiles, variablesfiles, SCons_XML.write_mod) # Step 2: Validating all input files -print "Validating files against SCons XSD..." +print("Validating files against SCons XSD...") if SConsDoc.validate_all_xml(['src']): - print "OK" + print("OK") else: - print "Validation failed! Please correct the errors above and try again." + print("Validation failed! Please correct the errors above and try again.") # Step 3: Creating actual documentation snippets, using the # fully resolved and updated entities from the *.mod files. -print "Updating documentation for builders, tools and functions..." +print("Updating documentation for builders, tools and functions...") h = parse_docs(args, True) write_output_files(h, buildersfiles, functionsfiles, toolsfiles, variablesfiles, SCons_XML.write) -print "Done" +print("Done") # Local Variables: # tab-width:4 diff --git a/bin/scons-test.py b/bin/scons-test.py index 046cf4b..788fc6d 100644 --- a/bin/scons-test.py +++ b/bin/scons-test.py @@ -60,7 +60,7 @@ for o, a in opts: outdir = a elif o == '-v' or o == '--verbose': def printname(x): - print x + print(x) elif o == '--xml': format = o @@ -148,34 +148,34 @@ else: if format == '--xml': - print "<scons_test_run>" - print " <sys>" + print("<scons_test_run>") + print(" <sys>") sys_keys = ['byteorder', 'exec_prefix', 'executable', 'maxint', 'maxunicode', 'platform', 'prefix', 'version', 'version_info'] for k in sys_keys: - print " <%s>%s</%s>" % (k, sys.__dict__[k], k) - print " </sys>" + print(" <%s>%s</%s>" % (k, sys.__dict__[k], k)) + print(" </sys>") fmt = '%a %b %d %H:%M:%S %Y' - print " <time>" - print " <gmtime>%s</gmtime>" % time.strftime(fmt, time.gmtime()) - print " <localtime>%s</localtime>" % time.strftime(fmt, time.localtime()) - print " </time>" + print(" <time>") + print(" <gmtime>%s</gmtime>" % time.strftime(fmt, time.gmtime())) + print(" <localtime>%s</localtime>" % time.strftime(fmt, time.localtime())) + print(" </time>") - print " <tempdir>%s</tempdir>" % tempdir + print(" <tempdir>%s</tempdir>" % tempdir) def print_version_info(tag, module): - print " <%s>" % tag - print " <version>%s</version>" % module.__version__ - print " <build>%s</build>" % module.__build__ - print " <buildsys>%s</buildsys>" % module.__buildsys__ - print " <date>%s</date>" % module.__date__ - print " <developer>%s</developer>" % module.__developer__ - print " </%s>" % tag - - print " <scons>" + print(" <%s>" % tag) + print(" <version>%s</version>" % module.__version__) + print(" <build>%s</build>" % module.__build__) + print(" <buildsys>%s</buildsys>" % module.__buildsys__) + print(" <date>%s</date>" % module.__date__) + print(" <developer>%s</developer>" % module.__developer__) + print(" </%s>" % tag) + + print(" <scons>") print_version_info("script", scons) print_version_info("engine", SCons) - print " </scons>" + print(" </scons>") environ_keys = [ 'PATH', @@ -213,32 +213,32 @@ if format == '--xml': 'USER', ] - print " <environment>" + print(" <environment>") for key in sorted(environ_keys): value = os.environ.get(key) if value: - print " <variable>" - print " <name>%s</name>" % key - print " <value>%s</value>" % value - print " </variable>" - print " </environment>" + print(" <variable>") + print(" <name>%s</name>" % key) + print(" <value>%s</value>" % value) + print(" </variable>") + print(" </environment>") command = '"%s" runtest.py -q -o - --xml %s' % (sys.executable, runtest_args) #print command os.system(command) - print "</scons_test_run>" + print("</scons_test_run>") else: def print_version_info(tag, module): - print "\t%s: v%s.%s, %s, by %s on %s" % (tag, + print("\t%s: v%s.%s, %s, by %s on %s" % (tag, module.__version__, module.__build__, module.__date__, module.__developer__, - module.__buildsys__) + module.__buildsys__)) - print "SCons by Steven Knight et al.:" + print("SCons by Steven Knight et al.:") print_version_info("script", scons) print_version_info("engine", SCons) diff --git a/bin/scons-unzip.py b/bin/scons-unzip.py index d4ec4bf..75d3281 100644 --- a/bin/scons-unzip.py +++ b/bin/scons-unzip.py @@ -32,7 +32,7 @@ for o, a in opts: outdir = a elif o == '-v' or o == '--verbose': def printname(x): - print x + print(x) if len(args) != 1: sys.stderr.write("scons-unzip.py: \n") diff --git a/bin/scons_dev_master.py b/bin/scons_dev_master.py index 3c41ac0..71034ad 100644 --- a/bin/scons_dev_master.py +++ b/bin/scons_dev_master.py @@ -131,12 +131,12 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER] try: try: opts, args = getopt.getopt(argv[1:], short_options, long_options) - except getopt.error, msg: + except getopt.error as msg: raise Usage(msg) for o, a in opts: if o in ('-h', '--help'): - print helpstr + print(helpstr) sys.exit(0) elif o in ('-n', '--no-exec'): CommandRunner.execute = CommandRunner.do_not_execute @@ -148,7 +148,7 @@ Usage: scons_dev_master.py [-hnqy] [--password PASSWORD] [--username USER] username = a elif o in ('-y', '--yes', '--assume-yes'): yesflag = o - except Usage, err: + except Usage as err: sys.stderr.write(str(err.msg) + '\n') sys.stderr.write('use -h to get help\n') return 2 diff --git a/bin/svn-bisect.py b/bin/svn-bisect.py index 77bda58..f262366 100755 --- a/bin/svn-bisect.py +++ b/bin/svn-bisect.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- Python -*- -from __future__ import division + import sys from math import log, ceil @@ -28,22 +28,22 @@ script = script_args[2:] # print an error message and quit def error(s): - print >>sys.stderr, "******", s, "******" + print("******", s, "******", file=sys.stderr) sys.exit(1) # update to the specified version and run test def testfail(revision): "Return true if test fails" - print "Updating to revision", revision + print("Updating to revision", revision) if subprocess.call(["svn","up","-qr",str(revision)]) != 0: m = "SVN did not update properly to revision %d" raise RuntimeError(m % revision) return subprocess.call(script,shell=False) != 0 # confirm that the endpoints are different -print "****** Checking upper bracket", upper +print("****** Checking upper bracket", upper) upperfails = testfail(upper) -print "****** Checking lower bracket", lower +print("****** Checking lower bracket", lower) lowerfails = testfail(lower) if upperfails == lowerfails: error("Upper and lower revisions must bracket the failure") @@ -51,7 +51,7 @@ if upperfails == lowerfails: # binary search for transition msg = "****** max %d revisions to test (bug bracketed by [%d,%d])" while upper-lower > 1: - print msg % (ceil(log(upper-lower,2)), lower, upper) + print(msg % (ceil(log(upper-lower,2)), lower, upper)) mid = (lower + upper)//2 midfails = testfail(mid) @@ -64,7 +64,7 @@ while upper-lower > 1: # show which revision was first to fail if upperfails != lowerfails: lower = upper -print "The error was caused by revision", lower +print("The error was caused by revision", lower) # Local Variables: # tab-width:4 diff --git a/bin/update-release-info.py b/bin/update-release-info.py index 338bba9..f60c187 100644 --- a/bin/update-release-info.py +++ b/bin/update-release-info.py @@ -73,14 +73,14 @@ if len(sys.argv) < 2: else: mode = sys.argv[1] if mode not in ['develop', 'release', 'post']: - print("""ERROR: `%s' as a parameter is invalid; it must be one of -\tdevelop, release, or post. The default is develop.""" % mode) + print(("""ERROR: `%s' as a parameter is invalid; it must be one of +\tdevelop, release, or post. The default is develop.""" % mode)) sys.exit(1) # Get configuration information config = dict() -exec open('ReleaseConfig').read() in globals(), config +exec(open('ReleaseConfig').read(), globals(), config) try: version_tuple = config['version_tuple'] @@ -90,9 +90,9 @@ except KeyError: print('''ERROR: Config file must contain at least version_tuple, \tunsupported_python_version, and deprecated_python_version.''') sys.exit(1) -if DEBUG: print 'version tuple', version_tuple -if DEBUG: print 'unsupported Python version', unsupported_version -if DEBUG: print 'deprecated Python version', deprecated_version +if DEBUG: print('version tuple', version_tuple) +if DEBUG: print('unsupported Python version', unsupported_version) +if DEBUG: print('deprecated Python version', deprecated_version) try: release_date = config['release_date'] @@ -102,9 +102,9 @@ else: if len(release_date) == 3: release_date = release_date + time.localtime()[3:6] if len(release_date) != 6: - print '''ERROR: Invalid release date''', release_date + print('''ERROR: Invalid release date''', release_date) sys.exit(1) -if DEBUG: print 'release date', release_date +if DEBUG: print('release date', release_date) if mode == 'develop' and version_tuple[3] != 'alpha': version_tuple == version_tuple[:3] + ('alpha', 0) @@ -119,11 +119,11 @@ if len(version_tuple) > 3: version_type = version_tuple[3] else: version_type = 'final' -if DEBUG: print 'version string', version_string +if DEBUG: print('version string', version_string) if version_type not in ['alpha', 'beta', 'candidate', 'final']: - print("""ERROR: `%s' is not a valid release type in version tuple; -\tit must be one of alpha, beta, candidate, or final""" % version_type) + print(("""ERROR: `%s' is not a valid release type in version tuple; +\tit must be one of alpha, beta, candidate, or final""" % version_type)) sys.exit(1) try: @@ -133,13 +133,13 @@ except KeyError: month_year = 'MONTH YEAR' else: month_year = time.strftime('%B %Y', release_date + (0,0,0)) -if DEBUG: print 'month year', month_year +if DEBUG: print('month year', month_year) try: copyright_years = config['copyright_years'] except KeyError: copyright_years = ', '.join(map(str, list(range(2001, release_date[0] + 1)))) -if DEBUG: print 'copyright years', copyright_years +if DEBUG: print('copyright years', copyright_years) class UpdateFile(object): """ @@ -218,7 +218,7 @@ class UpdateFile(object): XXX ''' if self.file is not None and self.content != self.orig: - print 'Updating ' + self.file + '...' + print('Updating ' + self.file + '...') open(self.file, 'w').write(self.content) if mode == 'post': @@ -332,7 +332,7 @@ t.replace_assign('deprecated_python_version', str(deprecated_version)) # Update doc/user/main.{in,xml} -docyears = ', '.join(map(str, iter(range(2004, release_date[0] + 1)))) +docyears = ', '.join(map(str, iter(list(range(2004, release_date[0] + 1))))) t = UpdateFile(os.path.join('doc', 'user', 'main.in')) if DEBUG: t.file = '/tmp/main.in' ## TODO debug these diff --git a/bin/xmlagenda.py b/bin/xmlagenda.py index b3cd520..40f5ca1 100755 --- a/bin/xmlagenda.py +++ b/bin/xmlagenda.py @@ -89,7 +89,7 @@ for issue in issues: writer.writerow(['','','','','','','']) for member in team: writer.writerow(['','',member,'','','','']) -print "Exported %d issues to editlist.csv. Ready to upload to Google."%len(issues) +print("Exported %d issues to editlist.csv. Ready to upload to Google."%len(issues)) # Local Variables: # tab-width:4 |