From 895990cbd5007876709b93e6d3db2b6c069382ea Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Sun, 22 Sep 2013 13:08:12 -0400 Subject: Result of raw 2to3 run (2to3-2.7); checkpoint for python3 conversion. --- bin/Command.py | 6 ++-- bin/SConsDoc.py | 28 +++++++++--------- bin/SConsExamples.py | 20 ++++++------- bin/calibrate.py | 8 ++--- bin/caller-tree.py | 10 +++---- bin/docs-create-example-outputs.py | 6 ++-- bin/docs-update-generated.py | 2 +- bin/docs-validate.py | 8 ++--- bin/install_python.py | 6 ++-- bin/install_scons.py | 10 +++---- bin/linecount.py | 30 +++++++++---------- bin/memlogs.py | 8 ++--- bin/memoicmp.py | 24 +++++++-------- bin/objcounts.py | 13 ++++----- bin/scons-diff.py | 14 ++++----- bin/scons-proc.py | 14 ++++----- bin/scons-test.py | 60 +++++++++++++++++++------------------- bin/scons-unzip.py | 2 +- bin/scons_dev_master.py | 6 ++-- bin/svn-bisect.py | 14 ++++----- bin/update-release-info.py | 30 +++++++++---------- bin/xmlagenda.py | 2 +- 22 files changed, 160 insertions(+), 161 deletions(-) (limited to 'bin') diff --git a/bin/Command.py b/bin/Command.py index 8702f51d..768caedc 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 dc9d161d..453e241d 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 9823a052..e3a7502a 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 8ed2ecea..31c04e80 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 03c1616a..327e6a11 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 30dc0eef..b2dfbea6 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 66b22c0b..2b419a47 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 c445c3f9..e5d06591 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 86807af6..dca37d0f 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 00129f65..b732193f 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 6f49dcad..2d478f0c 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 9d957c9f..0409dfee 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 812af665..5021c412 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 06620126..25b985b8 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 52bd51b1..5181fa17 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 9567db8c..19be4c37 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 046cf4b0..788fc6d1 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 "" - print " " + print("") + print(" ") sys_keys = ['byteorder', 'exec_prefix', 'executable', 'maxint', 'maxunicode', 'platform', 'prefix', 'version', 'version_info'] for k in sys_keys: - print " <%s>%s" % (k, sys.__dict__[k], k) - print " " + print(" <%s>%s" % (k, sys.__dict__[k], k)) + print(" ") fmt = '%a %b %d %H:%M:%S %Y' - print " " + print(" ") - print " %s" % tempdir + print(" %s" % tempdir) def print_version_info(tag, module): - print " <%s>" % tag - print " %s" % module.__version__ - print " %s" % module.__build__ - print " %s" % module.__buildsys__ - print " %s" % module.__date__ - print " %s" % module.__developer__ - print " " % tag - - print " " + print(" <%s>" % tag) + print(" %s" % module.__version__) + print(" %s" % module.__build__) + print(" %s" % module.__buildsys__) + print(" %s" % module.__date__) + print(" %s" % module.__developer__) + print(" " % tag) + + print(" ") print_version_info("script", scons) print_version_info("engine", SCons) - print " " + print(" ") environ_keys = [ 'PATH', @@ -213,32 +213,32 @@ if format == '--xml': 'USER', ] - print " " + print(" ") for key in sorted(environ_keys): value = os.environ.get(key) if value: - print " " - print " %s" % key - print " %s" % value - print " " - print " " + print(" ") + print(" %s" % key) + print(" %s" % value) + print(" ") + print(" ") command = '"%s" runtest.py -q -o - --xml %s' % (sys.executable, runtest_args) #print command os.system(command) - print "" + print("") 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 d4ec4bff..75d3281d 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 3c41ac06..71034ad5 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 77bda58f..f2623660 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 338bba91..f60c187d 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 b3cd5205..40f5ca14 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 -- cgit v1.2.1 From 15ad84e7cd33f33d287c63d6e00a221d859cce3b Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Mon, 31 Mar 2014 15:13:02 +0000 Subject: Made former 2to3 changes Python 2.7 compatible (or removed unneeded changes). --- bin/Command.py | 1 + bin/SConsDoc.py | 9 +++++---- bin/calibrate.py | 2 +- bin/caller-tree.py | 3 ++- bin/docs-create-example-outputs.py | 1 + bin/docs-update-generated.py | 1 + bin/docs-validate.py | 1 + bin/install_python.py | 1 + bin/install_scons.py | 8 ++++++-- bin/linecount.py | 2 +- bin/memlogs.py | 1 + bin/memoicmp.py | 9 +++++---- bin/objcounts.py | 5 +++-- bin/scons-diff.py | 5 +++-- bin/scons-proc.py | 4 +++- bin/scons-test.py | 5 +++-- bin/scons-unzip.py | 1 + bin/scons_dev_master.py | 1 + bin/sfsum | 11 ++++++----- bin/svn-bisect.py | 2 +- bin/update-release-info.py | 3 ++- bin/xmlagenda.py | 1 + 22 files changed, 50 insertions(+), 27 deletions(-) (limited to 'bin') diff --git a/bin/Command.py b/bin/Command.py index 768caedc..dadd7a9e 100644 --- a/bin/Command.py +++ b/bin/Command.py @@ -4,6 +4,7 @@ # # XXX Describe what the script does here. # +from __future__ import print_function import getopt import os diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 453e241d..80f41a58 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -24,6 +24,7 @@ # # Module for handling SCons documentation processing. # +from __future__ import print_function __doc__ = """ This module parses home-brew XML files that document various things @@ -51,7 +52,7 @@ Builder example: to indicate a new paragraph. - print "this is example code, it will be offset and indented" + print("this is example code, it will be offset and indented") @@ -71,7 +72,7 @@ Function example: &f-FUNCTION; element. It need not be on a line by itself. - print "this is example code, it will be offset and indented" + print("this is example code, it will be offset and indented") @@ -88,7 +89,7 @@ Construction variable example: &t-VARIABLE; element. It need not be on a line by itself. - print "this is example code, it will be offset and indented" + print("this is example code, it will be offset and indented") @@ -105,7 +106,7 @@ Tool example: &t-TOOL; element. It need not be on a line by itself. - print "this is example code, it will be offset and indented" + print("this is example code, it will be offset and indented") diff --git a/bin/calibrate.py b/bin/calibrate.py index 31c04e80..3f9104e1 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, print_function import optparse import os diff --git a/bin/caller-tree.py b/bin/caller-tree.py index 327e6a11..21cda4ba 100644 --- a/bin/caller-tree.py +++ b/bin/caller-tree.py @@ -39,6 +39,7 @@ # function at the same time, for example, their counts will intermix. # So use this to get a *general* idea of who's calling what, not for # fine-grained performance tuning. +from __future__ import print_function import sys @@ -86,7 +87,7 @@ def print_entry(e, level, calls): else: print() -for e in [ e for e in list(AllCalls.values()) if not e.calls ]: +for e in [ e for e in 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 b2dfbea6..64dcf2e2 100644 --- a/bin/docs-create-example-outputs.py +++ b/bin/docs-create-example-outputs.py @@ -3,6 +3,7 @@ # Searches through the whole doc/user tree and creates # all output files for the single examples. # +from __future__ import print_function import os import sys diff --git a/bin/docs-update-generated.py b/bin/docs-update-generated.py index 2b419a47..d22cc32e 100644 --- a/bin/docs-update-generated.py +++ b/bin/docs-update-generated.py @@ -6,6 +6,7 @@ # as well as the entity declarations for them. # Uses scons-proc.py under the hood... # +from __future__ import print_function import os import SConsDoc diff --git a/bin/docs-validate.py b/bin/docs-validate.py index e5d06591..e53a89de 100644 --- a/bin/docs-validate.py +++ b/bin/docs-validate.py @@ -3,6 +3,7 @@ # Searches through the whole source tree and validates all # documentation files against our own XSD in docs/xsd. # +from __future__ import print_function import sys,os import SConsDoc diff --git a/bin/install_python.py b/bin/install_python.py index dca37d0f..5c947ac8 100644 --- a/bin/install_python.py +++ b/bin/install_python.py @@ -6,6 +6,7 @@ # This was written for a Linux system (specifically Ubuntu) but should # be reasonably generic to any POSIX-style system with a /usr/local # hierarchy. +from __future__ import print_function import getopt import os diff --git a/bin/install_scons.py b/bin/install_scons.py index b732193f..7a39e963 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -17,13 +17,17 @@ # This was written for a Linux system (specifically Ubuntu) but should # be reasonably generic to any POSIX-style system with a /usr/local # hierarchy. +from __future__ import print_function import getopt import os import shutil import sys import tarfile -import urllib.request, urllib.parse, urllib.error +try: + from urllib.request import urlretrieve +except ImportError: # Python < 3 + from urllib import urlretrieve from Command import CommandRunner, Usage @@ -171,7 +175,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.request.urlretrieve, tar_gz_url, tar_gz), + cmd.run((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 2d478f0c..897f1e8f 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, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" diff --git a/bin/memlogs.py b/bin/memlogs.py index 0409dfee..6e68ce07 100644 --- a/bin/memlogs.py +++ b/bin/memlogs.py @@ -20,6 +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 print_function import getopt import sys diff --git a/bin/memoicmp.py b/bin/memoicmp.py index 5021c412..1106ac3c 100644 --- a/bin/memoicmp.py +++ b/bin/memoicmp.py @@ -2,6 +2,7 @@ # # A script to compare the --debug=memoizer output found in # two different files. +from future import print_function import sys @@ -29,14 +30,14 @@ def memoize_cmp(filea, fileb): ma_o = [] mb_o = [] mab = [] - for k in list(ma.keys()): - if k in list(mb.keys()): + for k in ma.keys(): + if k in mb.keys(): if k not in mab: mab.append(k) else: ma_o.append(k) - for k in list(mb.keys()): - if k in list(ma.keys()): + for k in mb.keys(): + if k in ma.keys(): if k not in mab: mab.append(k) else: diff --git a/bin/objcounts.py b/bin/objcounts.py index 25b985b8..2bd89236 100644 --- a/bin/objcounts.py +++ b/bin/objcounts.py @@ -20,6 +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 print_function import re import sys @@ -47,7 +48,7 @@ c1 = fetch_counts(sys.argv[1]) c2 = fetch_counts(sys.argv[2]) common = {} -for k in list(c1.keys()): +for k in c1.keys(): try: common[k] = (c1[k], c2[k]) except KeyError: @@ -58,7 +59,7 @@ for k in list(c1.keys()): if not '.' in k: s = '.'+k l = len(s) - for k2 in list(c2.keys()): + for k2 in c2.keys(): if k2[-l:] == s: common[k2] = (c1[k], c2[k2]) del c1[k] diff --git a/bin/scons-diff.py b/bin/scons-diff.py index 5181fa17..85975011 100644 --- a/bin/scons-diff.py +++ b/bin/scons-diff.py @@ -8,6 +8,7 @@ # etc. so that you can diff trees without having to ignore changes in # version lines. # +from __future__ import print_function import difflib import getopt @@ -161,7 +162,7 @@ def diff_file(left, right): else: if text: diff_line(left, right) - print(text, end=' ') + print(text) elif report_same: print('Files %s and %s are identical' % (left, right)) @@ -173,7 +174,7 @@ def diff_dir(left, right): u[l] = 1 for r in rlist: u[r] = 1 - for x in sorted([ x for x in list(u.keys()) if x[-4:] != '.pyc' ]): + for x in sorted([ x for x in u.keys() if x[-4:] != '.pyc' ]): if x in llist: if x in rlist: do_diff(os.path.join(left, x), diff --git a/bin/scons-proc.py b/bin/scons-proc.py index 19be4c37..b93b25a8 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -9,6 +9,8 @@ # DocBook-formatted generated XML files containing the summary text # and/or .mod files containing the ENTITY definitions for each item. # +from __future__ import print_function + import getopt import os import re @@ -106,7 +108,7 @@ Link_Entities_Header = """\ class SCons_XML(object): def __init__(self, entries, **kw): self.values = entries - for k, v in list(kw.items()): + for k, v in kw.items(): setattr(self, k, v) def fopen(self, name): diff --git a/bin/scons-test.py b/bin/scons-test.py index 788fc6d1..dd54dd14 100644 --- a/bin/scons-test.py +++ b/bin/scons-test.py @@ -14,6 +14,7 @@ # relevant information about the system, the Python version, etc., # so that problems on different platforms can be identified sooner. # +from __future__ import print_function import atexit import getopt @@ -224,7 +225,7 @@ if format == '--xml': print(" ") command = '"%s" runtest.py -q -o - --xml %s' % (sys.executable, runtest_args) - #print command + #print(command) os.system(command) print("") @@ -243,7 +244,7 @@ else: print_version_info("engine", SCons) command = '"%s" runtest.py %s' % (sys.executable, runtest_args) - #print command + #print(command) os.system(command) # Local Variables: diff --git a/bin/scons-unzip.py b/bin/scons-unzip.py index 75d3281d..a64179fc 100644 --- a/bin/scons-unzip.py +++ b/bin/scons-unzip.py @@ -7,6 +7,7 @@ # I'm using this to make it more convenient to manage working on multiple # changes on Windows, where I don't have access to my Aegis tools. # +from __future__ import print_function import getopt import os.path diff --git a/bin/scons_dev_master.py b/bin/scons_dev_master.py index 71034ad5..a8862ea8 100644 --- a/bin/scons_dev_master.py +++ b/bin/scons_dev_master.py @@ -3,6 +3,7 @@ # A script for turning a generic Ubuntu system into a master for # SCons development. +from __future__ import print_function import getopt import sys diff --git a/bin/sfsum b/bin/sfsum index 2dfa4224..142793af 100644 --- a/bin/sfsum +++ b/bin/sfsum @@ -22,6 +22,7 @@ # # https://sourceforge.net/projects/sitedocs/ # +from __future__ import print_function import xml.sax import xml.sax.saxutils @@ -121,9 +122,9 @@ if __name__ == '__main__': # generalized once we figure out other things for this script to do. bugs = [x for x in Artifacts['Bugs'] if x.status == 'Open'] - print list(Artifacts.keys()) + print(list(Artifacts.keys())) - print "%d open bugs" % len(bugs) + print("%d open bugs" % len(bugs)) # Sort them into a separate list for each assignee. Assigned = {} @@ -141,7 +142,7 @@ if __name__ == '__main__': except KeyError: pass else: - print " %s" % a - b.sort(lambda x, y: cmp(x.artifact_id, y.artifact_id)) + print(" %s" % a) + b.sort(key=lambda x, y: (x.artifact_id, y.artifact_id)) for bug in b: - print " %-6s %s" % (bug.artifact_id, bug.summary) + print(" %-6s %s" % (bug.artifact_id, bug.summary)) diff --git a/bin/svn-bisect.py b/bin/svn-bisect.py index f2623660..dbf8dd97 100755 --- a/bin/svn-bisect.py +++ b/bin/svn-bisect.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- Python -*- - +from __future__ import division, print_function import sys from math import log, ceil diff --git a/bin/update-release-info.py b/bin/update-release-info.py index f60c187d..b6cf9420 100644 --- a/bin/update-release-info.py +++ b/bin/update-release-info.py @@ -56,6 +56,7 @@ In 'post' mode, files are prepared for the next release cycle: # 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 print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -332,7 +333,7 @@ t.replace_assign('deprecated_python_version', str(deprecated_version)) # Update doc/user/main.{in,xml} -docyears = ', '.join(map(str, iter(list(range(2004, release_date[0] + 1))))) +docyears = ', '.join(map(str, 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 40f5ca14..fcfe53e2 100755 --- a/bin/xmlagenda.py +++ b/bin/xmlagenda.py @@ -18,6 +18,7 @@ # Grab the sort bar on the far left (just above the "1" for row one) # and move it down one row. (Row one becomes a floating header) # Voila! +from __future__ import print_function # The team members # FIXME: These names really should be external to this script -- cgit v1.2.1 From e0fbcd722d8ce5f02552157196c7b2e45dc362ee Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Mon, 31 Mar 2014 15:21:40 +0000 Subject: More __cmp__ to __eq__ (and __lt__). Resolved some UnboundLocalErrors after except. --- bin/SConsDoc.py | 6 ++++-- bin/scons-proc.py | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/SConsDoc.py b/bin/SConsDoc.py index 80f41a58..72c03064 100644 --- a/bin/SConsDoc.py +++ b/bin/SConsDoc.py @@ -668,8 +668,10 @@ class Item(object): if name[0] == '_': name = name[1:] return name.lower() - def __cmp__(self, other): - return cmp(self.sort_name, other.sort_name) + def __eq__(self, other): + return self.sort_name == other.sort_name + def __lt__(self, other): + return self.sort_name < other.sort_name class Builder(Item): pass diff --git a/bin/scons-proc.py b/bin/scons-proc.py index b93b25a8..138cff74 100644 --- a/bin/scons-proc.py +++ b/bin/scons-proc.py @@ -231,10 +231,15 @@ class Proxy(object): """Retrieve the entire wrapped object""" return self.__subject - def __cmp__(self, other): + def __eq__(self, other): if issubclass(other.__class__, self.__subject.__class__): - return cmp(self.__subject, other) - return cmp(self.__dict__, other.__dict__) + return self.__subject == other + return self.__dict__ == other.__dict__ + + ## def __lt__(self, other): + ## if issubclass(other.__class__, self.__subject.__class__): + ## return self.__subject < other + ## return self.__dict__ < other.__dict__ class SConsThing(Proxy): def idfunc(self): -- cgit v1.2.1 From 0605d2e54160580d65ed2e4f6f587e10876d32a8 Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Wed, 8 Jan 2014 13:25:16 +0000 Subject: Some more six.PY2/PY3 usage. --- bin/install_scons.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/install_scons.py b/bin/install_scons.py index 7a39e963..afd0789c 100644 --- a/bin/install_scons.py +++ b/bin/install_scons.py @@ -19,14 +19,16 @@ # hierarchy. from __future__ import print_function +from six import PY3 + import getopt import os import shutil import sys import tarfile -try: +if PY3: from urllib.request import urlretrieve -except ImportError: # Python < 3 +else: from urllib import urlretrieve from Command import CommandRunner, Usage -- cgit v1.2.1