diff options
author | Walter Dörwald <walter@livinglogic.de> | 2004-02-12 17:35:32 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2004-02-12 17:35:32 (GMT) |
commit | 70a6b49821a3226f55e9716f32d802d06640cb89 (patch) | |
tree | 3c8ca10c1fa09e025bd266cf855a00d7d96c55aa /Tools | |
parent | ecfeb7f095dfd9c1c8929bf3df858ee35e0d9e9e (diff) | |
download | cpython-70a6b49821a3226f55e9716f32d802d06640cb89.zip cpython-70a6b49821a3226f55e9716f32d802d06640cb89.tar.gz cpython-70a6b49821a3226f55e9716f32d802d06640cb89.tar.bz2 |
Replace backticks with repr() or "%r"
From SF patch #852334.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/bgen/bgen/scantools.py | 64 | ||||
-rw-r--r-- | Tools/compiler/compile.py | 3 | ||||
-rw-r--r-- | Tools/faqwiz/faqwiz.py | 8 | ||||
-rw-r--r-- | Tools/freeze/makefreeze.py | 2 | ||||
-rw-r--r-- | Tools/freeze/winmakemakefile.py | 2 | ||||
-rwxr-xr-x | Tools/modulator/modulator.py | 30 | ||||
-rwxr-xr-x | Tools/scripts/byteyears.py | 2 | ||||
-rwxr-xr-x | Tools/scripts/checkappend.py | 12 | ||||
-rwxr-xr-x | Tools/scripts/checkpyc.py | 18 | ||||
-rwxr-xr-x | Tools/scripts/classfix.py | 19 | ||||
-rwxr-xr-x | Tools/scripts/dutree.py | 2 | ||||
-rwxr-xr-x | Tools/scripts/fixcid.py | 18 | ||||
-rwxr-xr-x | Tools/scripts/fixps.py | 2 | ||||
-rwxr-xr-x | Tools/scripts/ftpmirror.py | 72 | ||||
-rwxr-xr-x | Tools/scripts/methfix.py | 19 | ||||
-rwxr-xr-x | Tools/scripts/pathfix.py | 16 | ||||
-rw-r--r-- | Tools/scripts/redemo.py | 2 | ||||
-rwxr-xr-x | Tools/scripts/suff.py | 2 | ||||
-rwxr-xr-x | Tools/scripts/texi2html.py | 20 | ||||
-rwxr-xr-x | Tools/scripts/untabify.py | 2 | ||||
-rwxr-xr-x | Tools/scripts/which.py | 2 |
21 files changed, 151 insertions, 166 deletions
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py index b9b6854..4afd7c8 100644 --- a/Tools/bgen/bgen/scantools.py +++ b/Tools/bgen/bgen/scantools.py @@ -151,7 +151,7 @@ if missing: raise "Missing Types" """ f = self.openrepairfile() if not f: return [] - print "Reading repair file", `f.name`, "..." + print "Reading repair file", repr(f.name), "..." list = [] lineno = 0 while 1: @@ -169,14 +169,14 @@ if missing: raise "Missing Types" if len(words) <> 3: print "Line", startlineno, print ": bad line (not 3 colon-separated fields)" - print `line` + print repr(line) continue [fpat, pat, rep] = words if not fpat: fpat = "*" if not pat: print "Line", startlineno, print "Empty pattern" - print `line` + print repr(line) continue patparts = [s.strip() for s in pat.split(',')] repparts = [s.strip() for s in rep.split(',')] @@ -185,13 +185,13 @@ if missing: raise "Missing Types" if not p: print "Line", startlineno, print "Empty pattern part" - print `line` + print repr(line) continue pattern = p.split() if len(pattern) > 3: print "Line", startlineno, print "Pattern part has > 3 words" - print `line` + print repr(line) pattern = pattern[:3] else: while len(pattern) < 3: @@ -202,13 +202,13 @@ if missing: raise "Missing Types" if not p: print "Line", startlineno, print "Empty replacement part" - print `line` + print repr(line) continue replacement = p.split() if len(replacement) > 3: print "Line", startlineno, print "Pattern part has > 3 words" - print `line` + print repr(line) replacement = replacement[:3] else: while len(replacement) < 3: @@ -224,7 +224,7 @@ if missing: raise "Missing Types" try: return open(filename, "rU") except IOError, msg: - print `filename`, ":", msg + print repr(filename), ":", msg print "Cannot open repair file -- assume no repair needed" return None @@ -360,7 +360,7 @@ if missing: raise "Missing Types" if not os.path.isabs(filename): for dir in self.includepath: fullname = os.path.join(dir, filename) - #self.report("trying full name %s", `fullname`) + #self.report("trying full name %r", fullname) try: return open(fullname, 'rU') except IOError: @@ -387,17 +387,17 @@ if missing: raise "Missing Types" self.error("No input file has been specified") return inputname = self.scanfile.name - self.report("scanfile = %s", `inputname`) + self.report("scanfile = %r", inputname) if not self.specfile: self.report("(No interface specifications will be written)") else: - self.report("specfile = %s", `self.specfile.name`) - self.specfile.write("# Generated from %s\n\n" % `inputname`) + self.report("specfile = %r", self.specfile.name) + self.specfile.write("# Generated from %r\n\n" % (inputname,)) if not self.defsfile: self.report("(No symbol definitions will be written)") else: - self.report("defsfile = %s", `self.defsfile.name`) - self.defsfile.write("# Generated from %s\n\n" % `os.path.split(inputname)[1]`) + self.report("defsfile = %r", (self.defsfile.name,)) + self.defsfile.write("# Generated from %r\n\n" % (os.path.split(inputname)[1],)) self.writeinitialdefs() self.alreadydone = [] try: @@ -405,17 +405,17 @@ if missing: raise "Missing Types" try: line = self.getline() except EOFError: break if self.debug: - self.report("LINE: %s" % `line`) + self.report("LINE: %r" % (line,)) match = self.comment1.match(line) if match: line = match.group('rest') if self.debug: - self.report("\tafter comment1: %s" % `line`) + self.report("\tafter comment1: %r" % (line,)) match = self.comment2.match(line) while match: line = match.group('rest1')+match.group('rest2') if self.debug: - self.report("\tafter comment2: %s" % `line`) + self.report("\tafter comment2: %r" % (line,)) match = self.comment2.match(line) if self.defsfile: match = self.sym.match(line) @@ -438,7 +438,7 @@ if missing: raise "Missing Types" name, defn = match.group('name', 'defn') defn = escape8bit(defn) if self.debug: - self.report("\tsym: name=%s, defn=%s" % (`name`, `defn`)) + self.report("\tsym: name=%r, defn=%r" % (name, defn)) if not name in self.blacklistnames: self.defsfile.write("%s = %s\n" % (name, defn)) else: @@ -450,27 +450,27 @@ if missing: raise "Missing Types" while not self.tail.search(raw): line = self.getline() if self.debug: - self.report("* CONTINUATION LINE: %s" % `line`) + self.report("* CONTINUATION LINE: %r" % (line,)) match = self.comment1.match(line) if match: line = match.group('rest') if self.debug: - self.report("\tafter comment1: %s" % `line`) + self.report("\tafter comment1: %r" % (line,)) match = self.comment2.match(line) while match: line = match.group('rest1')+match.group('rest2') if self.debug: - self.report("\tafter comment1: %s" % `line`) + self.report("\tafter comment1: %r" % (line,)) match = self.comment2.match(line) raw = raw + line if self.debug: - self.report("* WHOLE LINE: %s" % `raw`) + self.report("* WHOLE LINE: %r" % (raw,)) self.processrawspec(raw) def processrawspec(self, raw): match = self.whole.search(raw) if not match: - self.report("Bad raw spec: %s", `raw`) + self.report("Bad raw spec: %r", raw) if self.debug: if not self.type.search(raw): self.report("(Type already doesn't match)") @@ -481,7 +481,7 @@ if missing: raise "Missing Types" type = re.sub("\*", " ptr", type) type = re.sub("[ \t]+", "_", type) if name in self.alreadydone: - self.report("Name has already been defined: %s", `name`) + self.report("Name has already been defined: %r", name) return self.report("==> %s %s <==", type, name) if self.blacklisted(type, name): @@ -494,7 +494,7 @@ if missing: raise "Missing Types" arglist = self.repairarglist(name, arglist) if self.unmanageable(type, name, arglist): ##for arg in arglist: - ## self.report(" %s", `arg`) + ## self.report(" %r", arg) self.report("*** %s %s unmanageable", type, name) return self.alreadydone.append(name) @@ -516,7 +516,7 @@ if missing: raise "Missing Types" part = part.strip() match = self.asplit.match(part) if not match: - self.error("Indecipherable argument: %s", `part`) + self.error("Indecipherable argument: %r", part) return ("unknown", part, mode) type, name, array = match.group('type', 'name', 'array') if array: @@ -583,21 +583,21 @@ if missing: raise "Missing Types" index = int(item[i][1:]) - 1 newitem[i] = old[index][i] new.append(tuple(newitem)) - ##self.report("old: %s", `old`) - ##self.report("new: %s", `new`) + ##self.report("old: %r", old) + ##self.report("new: %r", new) return new def generate(self, type, name, arglist): self.typeused(type, 'return') classname, listname = self.destination(type, name, arglist) if not self.specfile: return - self.specfile.write("f = %s(%s, %s,\n" % (classname, type, `name`)) + self.specfile.write("f = %s(%s, %r,\n" % (classname, type, name)) for atype, aname, amode in arglist: self.typeused(atype, amode) - self.specfile.write(" (%s, %s, %s),\n" % - (atype, `aname`, amode)) + self.specfile.write(" (%s, %r, %s),\n" % + (atype, aname, amode)) if self.greydictnames.has_key(name): - self.specfile.write(" condition=%s,\n"%`self.greydictnames[name]`) + self.specfile.write(" condition=%r,\n"%(self.greydictnames[name],)) self.specfile.write(")\n") self.specfile.write("%s.append(f)\n\n" % listname) diff --git a/Tools/compiler/compile.py b/Tools/compiler/compile.py index c90d851..c1483c5 100644 --- a/Tools/compiler/compile.py +++ b/Tools/compiler/compile.py @@ -35,8 +35,7 @@ def main(): print filename try: if PROFILE: - profile.run('compileFile(%s, %s)' % (`filename`, - `DISPLAY`), + profile.run('compileFile(%r, %r)' % (filename, DISPLAY), filename + ".prof") else: compileFile(filename, DISPLAY) diff --git a/Tools/faqwiz/faqwiz.py b/Tools/faqwiz/faqwiz.py index e91d4dc..a44da12 100644 --- a/Tools/faqwiz/faqwiz.py +++ b/Tools/faqwiz/faqwiz.py @@ -383,7 +383,7 @@ class FaqWizard: try: meth = getattr(self, mname) except AttributeError: - self.error("Bad request type %s." % `req`) + self.error("Bad request type %r." % (req,)) else: try: meth() @@ -664,7 +664,7 @@ class FaqWizard: rev = self.ui.rev mami = revparse(rev) if not mami: - self.error("Invalid revision number: %s." % `rev`) + self.error("Invalid revision number: %r." % (rev,)) self.prologue(T_REVISION, entry) self.shell(interpolate(SH_REVISION, entry, rev=rev)) @@ -674,10 +674,10 @@ class FaqWizard: rev = self.ui.rev mami = revparse(rev) if not mami: - self.error("Invalid revision number: %s." % `rev`) + self.error("Invalid revision number: %r." % (rev,)) if prev: if not revparse(prev): - self.error("Invalid previous revision number: %s." % `prev`) + self.error("Invalid previous revision number: %r." % (prev,)) else: prev = '%d.%d' % (mami[0], mami[1]) self.prologue(T_DIFF, entry) diff --git a/Tools/freeze/makefreeze.py b/Tools/freeze/makefreeze.py index 29a6ad6..9ff348c 100644 --- a/Tools/freeze/makefreeze.py +++ b/Tools/freeze/makefreeze.py @@ -87,4 +87,4 @@ def writecode(outfp, mod, str): ## def writecode(outfp, mod, str): ## outfp.write('unsigned char M_%s[%d] = "%s";\n' % (mod, len(str), -## '\\"'.join(map(lambda s: `s`[1:-1], str.split('"'))))) +## '\\"'.join(map(lambda s: repr(s)[1:-1], str.split('"'))))) diff --git a/Tools/freeze/winmakemakefile.py b/Tools/freeze/winmakemakefile.py index 763e820..8570f3d 100644 --- a/Tools/freeze/winmakemakefile.py +++ b/Tools/freeze/winmakemakefile.py @@ -51,7 +51,7 @@ def makemakefile(outfp, vars, files, target): sys.stdout = save def realwork(vars, moddefns, target): - version_suffix = `sys.version_info[0]`+`sys.version_info[1]` + version_suffix = "%r%r" % sys.version_info[:2] print "# Makefile for Microsoft Visual C++ generated by freeze.py script" print print 'target = %s' % target diff --git a/Tools/modulator/modulator.py b/Tools/modulator/modulator.py index df6d9ef..4828743 100755 --- a/Tools/modulator/modulator.py +++ b/Tools/modulator/modulator.py @@ -216,15 +216,15 @@ class UI_module: o.synchronize() onames = [] for i in range(len(objects)): - oname = 'o'+`i+1` + oname = 'o%d' % (i+1) rv = rv + objects[i].gencode(oname) onames.append(oname) - rv = rv + (name+' = genmodule.module()\n') - rv = rv + (name+'.name = '+`self.name_entry.get()`+'\n') - rv = rv + (name+'.abbrev = '+`self.abbrev_entry.get()`+'\n') - rv = rv + (name+'.methodlist = '+`getlistlist(self.method_list)`+'\n') - rv = rv + (name+'.objects = ['+','.join(onames)+']\n') - rv = rv + ('\n') + rv = rv + '%s = genmodule.module()\n' % (name,) + rv = rv + '%s.name = %r\n' % (name, self.name_entry.get()) + rv = rv + '%s.abbrev = %r\n' % (name, self.abbrev_entry.get()) + rv = rv + '%s.methodlist = %r\n' % (name, getlistlist(self.method_list)) + rv = rv + '%s.objects = [%s]\n' % (name, ','.join(onames)) + rv = rv + '\n' return rv object_number = 0 @@ -235,7 +235,7 @@ class UI_object: object_number = object_number + 1 self.num = object_number - self.vpref = 'o'+`self.num`+'_' + self.vpref = 'o%r_' % self.num self.frame = Toplevel(parent.objframe) # self.frame.pack() self.frame.title('Modulator: object view') @@ -340,16 +340,16 @@ class UI_object: def gencode(self, name): rv = '' - rv = rv + (name+' = genmodule.object()\n') - rv = rv + (name+'.name = '+`self.name_entry.get()`+'\n') - rv = rv + (name+'.abbrev = '+`self.abbrev_entry.get()`+'\n') - rv = rv + (name+'.methodlist = '+`getlistlist(self.method_list)`+'\n') + rv = rv + '%s = genmodule.object()\n' % (name,) + rv = rv + '%s.name = %r\n' % (name, self.name_entry.get()) + rv = rv + '%s.abbrev = %r\n' % (name, self.abbrev_entry.get()) + rv = rv + '%s.methodlist = %r\n' % (name, getlistlist(self.method_list)) fl = [] for fn in genmodule.FUNCLIST: vname = self.vpref + fn if self.f5.getvar(vname) == '1': fl.append(fn) - rv = rv + (name+'.funclist = '+`fl`+'\n') + rv = rv + '%s.funclist = %r\n' % (name, fl) fl = [] for fn in genmodule.TYPELIST: @@ -357,9 +357,9 @@ class UI_object: if self.f5.getvar(vname) == '1': fl.append(fn) - rv = rv + (name+'.typelist = '+`fl`+'\n') + rv = rv + '%s.typelist = %r\n' % (name, fl) - rv = rv + ('\n') + rv = rv + '\n' return rv diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py index 9c2a974..b2a114f 100755 --- a/Tools/scripts/byteyears.py +++ b/Tools/scripts/byteyears.py @@ -42,7 +42,7 @@ for filename in sys.argv[1:]: try: st = statfunc(filename) except os.error, msg: - sys.stderr.write('can\'t stat ' + `filename` + ': ' + `msg` + '\n') + sys.stderr.write("can't stat %r: %r\n" % (filename, msg)) status = 1 st = () if st: diff --git a/Tools/scripts/checkappend.py b/Tools/scripts/checkappend.py index b3141df..a8714d9 100755 --- a/Tools/scripts/checkappend.py +++ b/Tools/scripts/checkappend.py @@ -65,7 +65,7 @@ def main(): def check(file): if os.path.isdir(file) and not os.path.islink(file): if verbose: - print "%s: listing directory" % `file` + print "%r: listing directory" % (file,) names = os.listdir(file) for name in names: fullname = os.path.join(file, name) @@ -78,15 +78,15 @@ def check(file): try: f = open(file) except IOError, msg: - errprint("%s: I/O Error: %s" % (`file`, str(msg))) + errprint("%r: I/O Error: %s" % (file, msg)) return if verbose > 1: - print "checking", `file`, "..." + print "checking %r ..." % (file,) ok = AppendChecker(file, f).run() if verbose and ok: - print "%s: Clean bill of health." % `file` + print "%r: Clean bill of health." % (file,) [FIND_DOT, FIND_APPEND, @@ -105,7 +105,7 @@ class AppendChecker: try: tokenize.tokenize(self.file.readline, self.tokeneater) except tokenize.TokenError, msg: - errprint("%s: Token Error: %s" % (`self.fname`, str(msg))) + errprint("%r: Token Error: %s" % (self.fname, msg)) self.nerrors = self.nerrors + 1 return self.nerrors == 0 @@ -159,7 +159,7 @@ class AppendChecker: state = FIND_DOT else: - raise SystemError("unknown internal state '%s'" % `state`) + raise SystemError("unknown internal state '%r'" % (state,)) self.state = state diff --git a/Tools/scripts/checkpyc.py b/Tools/scripts/checkpyc.py index b38b456..d5f3c7a 100755 --- a/Tools/scripts/checkpyc.py +++ b/Tools/scripts/checkpyc.py @@ -17,15 +17,15 @@ def main(): silent = 1 MAGIC = imp.get_magic() if not silent: - print 'Using MAGIC word', `MAGIC` + print 'Using MAGIC word', repr(MAGIC) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: - print 'Cannot list directory', `dirname` + print 'Cannot list directory', repr(dirname) continue if not silent: - print 'Checking', `dirname`, '...' + print 'Checking ', repr(dirname), '...' names.sort() for name in names: if name[-3:] == '.py': @@ -33,29 +33,29 @@ def main(): try: st = os.stat(name) except os.error: - print 'Cannot stat', `name` + print 'Cannot stat', repr(name) continue if verbose: - print 'Check', `name`, '...' + print 'Check', repr(name), '...' name_c = name + 'c' try: f = open(name_c, 'r') except IOError: - print 'Cannot open', `name_c` + print 'Cannot open', repr(name_c) continue magic_str = f.read(4) mtime_str = f.read(4) f.close() if magic_str <> MAGIC: print 'Bad MAGIC word in ".pyc" file', - print `name_c` + print repr(name_c) continue mtime = get_long(mtime_str) if mtime == 0 or mtime == -1: - print 'Bad ".pyc" file', `name_c` + print 'Bad ".pyc" file', repr(name_c) elif mtime <> st[ST_MTIME]: print 'Out-of-date ".pyc" file', - print `name_c` + print repr(name_c) def get_long(s): if len(s) <> 4: diff --git a/Tools/scripts/classfix.py b/Tools/scripts/classfix.py index 7b86aa3..520b352 100755 --- a/Tools/scripts/classfix.py +++ b/Tools/scripts/classfix.py @@ -58,12 +58,12 @@ def ispython(name): return ispythonprog.match(name) >= 0 def recursedown(dirname): - dbg('recursedown(' + `dirname` + ')\n') + dbg('recursedown(%r)\n' % (dirname,)) bad = 0 try: names = os.listdir(dirname) except os.error, msg: - err(dirname + ': cannot list directory: ' + `msg` + '\n') + err('%s: cannot list directory: %r\n' % (dirname, msg)) return 1 names.sort() subdirs = [] @@ -80,11 +80,11 @@ def recursedown(dirname): return bad def fix(filename): -## dbg('fix(' + `filename` + ')\n') +## dbg('fix(%r)\n' % (filename,)) try: f = open(filename, 'r') except IOError, msg: - err(filename + ': cannot open: ' + `msg` + '\n') + err('%s: cannot open: %r\n' % (filename, msg)) return 1 head, tail = os.path.split(filename) tempname = os.path.join(head, '@' + tail) @@ -108,14 +108,13 @@ def fix(filename): g = open(tempname, 'w') except IOError, msg: f.close() - err(tempname+': cannot create: '+\ - `msg`+'\n') + err('%s: cannot create: %r\n' % (tempname, msg)) return 1 f.seek(0) lineno = 0 rep(filename + ':\n') continue # restart from the beginning - rep(`lineno` + '\n') + rep(repr(lineno) + '\n') rep('< ' + line) rep('> ' + newline) if g is not None: @@ -132,17 +131,17 @@ def fix(filename): statbuf = os.stat(filename) os.chmod(tempname, statbuf[ST_MODE] & 07777) except os.error, msg: - err(tempname + ': warning: chmod failed (' + `msg` + ')\n') + err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ try: os.rename(filename, filename + '~') except os.error, msg: - err(filename + ': warning: backup failed (' + `msg` + ')\n') + err('%s: warning: backup failed (%r)\n' % (filename, msg)) # Now move the temp file to the original file try: os.rename(tempname, filename) except os.error, msg: - err(filename + ': rename failed (' + `msg` + ')\n') + err('%s: rename failed (%r)\n' % (filename, msg)) return 1 # Return succes return 0 diff --git a/Tools/scripts/dutree.py b/Tools/scripts/dutree.py index 857a5cc..a49d80a 100755 --- a/Tools/scripts/dutree.py +++ b/Tools/scripts/dutree.py @@ -46,7 +46,7 @@ def show(total, d, prefix): ## list.append((total - sum, os.curdir)) list.sort() list.reverse() - width = len(`list[0][0]`) + width = len(repr(list[0][0])) for tsub, key in list: if tsub is None: psub = prefix diff --git a/Tools/scripts/fixcid.py b/Tools/scripts/fixcid.py index 8bc1de0..76841fe 100755 --- a/Tools/scripts/fixcid.py +++ b/Tools/scripts/fixcid.py @@ -93,7 +93,7 @@ def wanted(name): return regex.match(Wanted, name) >= 0 def recursedown(dirname): - dbg('recursedown(' + `dirname` + ')\n') + dbg('recursedown(%r)\n' % (dirname,)) bad = 0 try: names = os.listdir(dirname) @@ -115,7 +115,7 @@ def recursedown(dirname): return bad def fix(filename): -## dbg('fix(' + `filename` + ')\n') +## dbg('fix(%r)\n' % (filename,)) if filename == '-': # Filter mode f = sys.stdin @@ -158,7 +158,7 @@ def fix(filename): initfixline() rep(filename + ':\n') continue # restart from the beginning - rep(`lineno` + '\n') + rep(repr(lineno) + '\n') rep('< ' + line) rep('> ' + newline) if g is not None: @@ -225,7 +225,7 @@ def initfixline(): def fixline(line): global Program -## print '-->', `line` +## print '-->', repr(line) i = 0 while i < len(line): i = Program.search(line, i) @@ -293,8 +293,7 @@ def addsubst(substfile): if len(words) == 3 and words[0] == 'struct': words[:2] = [words[0] + ' ' + words[1]] elif len(words) <> 2: - err(substfile + ':' + `lineno` + - ': warning: bad line: ' + line) + err(substfile + '%s:%r: warning: bad line: %r' % (substfile, lineno, line)) continue if Reverse: [value, key] = words @@ -306,11 +305,8 @@ def addsubst(substfile): key = key[1:] NotInComment[key] = value if Dict.has_key(key): - err(substfile + ':' + `lineno` + - ': warning: overriding: ' + - key + ' ' + value + '\n') - err(substfile + ':' + `lineno` + - ': warning: previous: ' + Dict[key] + '\n') + err('%s:%r: warning: overriding: %r %r\n' % (substfile, lineno, key, value)) + err('%s:%r: warning: previous: %r\n' % (substfile, lineno, Dict[key])) Dict[key] = value fp.close() diff --git a/Tools/scripts/fixps.py b/Tools/scripts/fixps.py index e406571..12e9f43 100755 --- a/Tools/scripts/fixps.py +++ b/Tools/scripts/fixps.py @@ -23,7 +23,7 @@ def main(): f.close() line = re.sub('/usr/local/bin/python', '/usr/bin/env python', line) - print filename, ':', `line` + print filename, ':', repr(line) f = open(filename, "w") f.write(line) f.write(rest) diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py index 41607b0..0f918b8 100755 --- a/Tools/scripts/ftpmirror.py +++ b/Tools/scripts/ftpmirror.py @@ -87,17 +87,17 @@ def main(): f.connect(host,port) if not nologin: if verbose: - print 'Logging in as %s...' % `login or 'anonymous'` + print 'Logging in as %r...' % (login or 'anonymous') f.login(login, passwd, account) if verbose: print 'OK.' pwd = f.pwd() - if verbose > 1: print 'PWD =', `pwd` + if verbose > 1: print 'PWD =', repr(pwd) if remotedir: - if verbose > 1: print 'cwd(%s)' % `remotedir` + if verbose > 1: print 'cwd(%s)' % repr(remotedir) f.cwd(remotedir) if verbose > 1: print 'OK.' pwd = f.pwd() - if verbose > 1: print 'PWD =', `pwd` + if verbose > 1: print 'PWD =', repr(pwd) # mirrorsubdir(f, localdir) @@ -105,11 +105,11 @@ def main(): def mirrorsubdir(f, localdir): pwd = f.pwd() if localdir and not os.path.isdir(localdir): - if verbose: print 'Creating local directory', `localdir` + if verbose: print 'Creating local directory', repr(localdir) try: makedir(localdir) except os.error, msg: - print "Failed to establish local directory", `localdir` + print "Failed to establish local directory", repr(localdir) return infofilename = os.path.join(localdir, '.mirrorinfo') try: @@ -119,15 +119,15 @@ def mirrorsubdir(f, localdir): try: info = eval(text) except (SyntaxError, NameError): - print 'Bad mirror info in %s' % `infofilename` + print 'Bad mirror info in', repr(infofilename) info = {} subdirs = [] listing = [] - if verbose: print 'Listing remote directory %s...' % `pwd` + if verbose: print 'Listing remote directory %r...' % (pwd,) f.retrlines('LIST', listing.append) filesfound = [] for line in listing: - if verbose > 1: print '-->', `line` + if verbose > 1: print '-->', repr(line) if mac: # Mac listing has just filenames; # trailing / means subdirectory @@ -148,7 +148,7 @@ def mirrorsubdir(f, localdir): if i >= 0: # words[0] had better start with 'l'... if verbose > 1: - print 'Found symbolic link %s' % `filename` + print 'Found symbolic link %r' % (filename,) linkto = filename[i+4:] filename = filename[:i] infostuff = words[-5:-1] @@ -157,21 +157,21 @@ def mirrorsubdir(f, localdir): for pat in skippats: if fnmatch(filename, pat): if verbose > 1: - print 'Skip pattern', `pat`, - print 'matches', `filename` + print 'Skip pattern', repr(pat), + print 'matches', repr(filename) skip = 1 break if skip: continue if mode[0] == 'd': if verbose > 1: - print 'Remembering subdirectory', `filename` + print 'Remembering subdirectory', repr(filename) subdirs.append(filename) continue filesfound.append(filename) if info.has_key(filename) and info[filename] == infostuff: if verbose > 1: - print 'Already have this version of',`filename` + print 'Already have this version of',repr(filename) continue fullname = os.path.join(localdir, filename) tempname = os.path.join(localdir, '@'+filename) @@ -187,24 +187,20 @@ def mirrorsubdir(f, localdir): pass if mode[0] == 'l': if verbose: - print "Creating symlink %s -> %s" % ( - `filename`, `linkto`) + print "Creating symlink %r -> %r" % (filename, linkto) try: os.symlink(linkto, tempname) except IOError, msg: - print "Can't create %s: %s" % ( - `tempname`, str(msg)) + print "Can't create %r: %s" % (tempname, msg) continue else: try: fp = open(tempname, 'wb') except IOError, msg: - print "Can't create %s: %s" % ( - `tempname`, str(msg)) + print "Can't create %r: %s" % (tempname, msg) continue if verbose: - print 'Retrieving %s from %s as %s...' % \ - (`filename`, `pwd`, `fullname`) + print 'Retrieving %r from %r as %r...' % (filename, pwd, fullname) if verbose: fp1 = LoggingFile(fp, 1024, sys.stdout) else: @@ -227,9 +223,7 @@ def mirrorsubdir(f, localdir): try: os.rename(tempname, fullname) except os.error, msg: - print "Can't rename %s to %s: %s" % (`tempname`, - `fullname`, - str(msg)) + print "Can't rename %r to %r: %s" % (tempname, fullname, msg) continue info[filename] = infostuff writedict(info, infofilename) @@ -251,7 +245,7 @@ def mirrorsubdir(f, localdir): if filename not in filesfound: if verbose: print "Removing obsolete info entry for", - print `filename`, "in", `localdir or "."` + print repr(filename), "in", repr(localdir or ".") del info[filename] deletions = deletions + 1 if deletions: @@ -270,8 +264,8 @@ def mirrorsubdir(f, localdir): for pat in skippats: if fnmatch(name, pat): if verbose > 1: - print 'Skip pattern', `pat`, - print 'matches', `name` + print 'Skip pattern', repr(pat), + print 'matches', repr(name) skip = 1 break if skip: @@ -279,10 +273,10 @@ def mirrorsubdir(f, localdir): fullname = os.path.join(localdir, name) if not rmok: if verbose: - print 'Local file', `fullname`, + print 'Local file', repr(fullname), print 'is no longer pertinent' continue - if verbose: print 'Removing local file/dir', `fullname` + if verbose: print 'Removing local file/dir', repr(fullname) remove(fullname) # # Recursively mirror subdirectories @@ -290,18 +284,18 @@ def mirrorsubdir(f, localdir): if interactive: doit = askabout('subdirectory', subdir, pwd) if not doit: continue - if verbose: print 'Processing subdirectory', `subdir` + if verbose: print 'Processing subdirectory', repr(subdir) localsubdir = os.path.join(localdir, subdir) pwd = f.pwd() if verbose > 1: - print 'Remote directory now:', `pwd` - print 'Remote cwd', `subdir` + print 'Remote directory now:', repr(pwd) + print 'Remote cwd', repr(subdir) try: f.cwd(subdir) except ftplib.error_perm, msg: - print "Can't chdir to", `subdir`, ":", `msg` + print "Can't chdir to", repr(subdir), ":", repr(msg) else: - if verbose: print 'Mirroring as', `localsubdir` + if verbose: print 'Mirroring as', repr(localsubdir) mirrorsubdir(f, localsubdir) if verbose > 1: print 'Remote cwd ..' f.cwd('..') @@ -329,15 +323,13 @@ def remove(fullname): try: os.rmdir(fullname) except os.error, msg: - print "Can't remove local directory %s: %s" % \ - (`fullname`, str(msg)) + print "Can't remove local directory %r: %s" % (fullname, msg) return 0 else: try: os.unlink(fullname) except os.error, msg: - print "Can't remove local file %s: %s" % \ - (`fullname`, str(msg)) + print "Can't remove local file %r: %s" % (fullname, msg) return 0 return 1 @@ -394,7 +386,7 @@ def writedict(dict, filename): fp = open(tempname, 'w') fp.write('{\n') for key, value in dict.items(): - fp.write('%s: %s,\n' % (`key`, `value`)) + fp.write('%r: %r,\n' % (key, value)) fp.write('}\n') fp.close() try: diff --git a/Tools/scripts/methfix.py b/Tools/scripts/methfix.py index 9e69961..9200d265 100755 --- a/Tools/scripts/methfix.py +++ b/Tools/scripts/methfix.py @@ -55,12 +55,12 @@ def ispython(name): return ispythonprog.match(name) >= 0 def recursedown(dirname): - dbg('recursedown(' + `dirname` + ')\n') + dbg('recursedown(%r)\n' % (dirname,)) bad = 0 try: names = os.listdir(dirname) except os.error, msg: - err(dirname + ': cannot list directory: ' + `msg` + '\n') + err('%s: cannot list directory: %r\n' % (dirname, msg)) return 1 names.sort() subdirs = [] @@ -77,11 +77,11 @@ def recursedown(dirname): return bad def fix(filename): -## dbg('fix(' + `filename` + ')\n') +## dbg('fix(%r)\n' % (filename,)) try: f = open(filename, 'r') except IOError, msg: - err(filename + ': cannot open: ' + `msg` + '\n') + err('%s: cannot open: %r\n' % (filename, msg)) return 1 head, tail = os.path.split(filename) tempname = os.path.join(head, '@' + tail) @@ -119,14 +119,13 @@ def fix(filename): g = open(tempname, 'w') except IOError, msg: f.close() - err(tempname+': cannot create: '+\ - `msg`+'\n') + err('%s: cannot create: %r\n' % (tempname, msg)) return 1 f.seek(0) lineno = 0 rep(filename + ':\n') continue # restart from the beginning - rep(`lineno` + '\n') + rep(repr(lineno) + '\n') rep('< ' + line) rep('> ' + newline) if g is not None: @@ -143,17 +142,17 @@ def fix(filename): statbuf = os.stat(filename) os.chmod(tempname, statbuf[ST_MODE] & 07777) except os.error, msg: - err(tempname + ': warning: chmod failed (' + `msg` + ')\n') + err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ try: os.rename(filename, filename + '~') except os.error, msg: - err(filename + ': warning: backup failed (' + `msg` + ')\n') + err('%s: warning: backup failed (%r)\n' % (filename, msg)) # Now move the temp file to the original file try: os.rename(tempname, filename) except os.error, msg: - err(filename + ': rename failed (' + `msg` + ')\n') + err('%s: rename failed (%r)\n' % (filename, msg)) return 1 # Return succes return 0 diff --git a/Tools/scripts/pathfix.py b/Tools/scripts/pathfix.py index 81c5a6e..47ae464 100755 --- a/Tools/scripts/pathfix.py +++ b/Tools/scripts/pathfix.py @@ -64,12 +64,12 @@ def ispython(name): return ispythonprog.match(name) >= 0 def recursedown(dirname): - dbg('recursedown(' + `dirname` + ')\n') + dbg('recursedown(%r)\n' % (dirname,)) bad = 0 try: names = os.listdir(dirname) except os.error, msg: - err(dirname + ': cannot list directory: ' + `msg` + '\n') + err('%s: cannot list directory: %r\n' % (dirname, msg)) return 1 names.sort() subdirs = [] @@ -86,11 +86,11 @@ def recursedown(dirname): return bad def fix(filename): -## dbg('fix(' + `filename` + ')\n') +## dbg('fix(%r)\n' % (filename,)) try: f = open(filename, 'r') except IOError, msg: - err(filename + ': cannot open: ' + `msg` + '\n') + err('%s: cannot open: %r\n' % (filename, msg)) return 1 line = f.readline() fixed = fixline(line) @@ -104,7 +104,7 @@ def fix(filename): g = open(tempname, 'w') except IOError, msg: f.close() - err(tempname+': cannot create: '+`msg`+'\n') + err('%s: cannot create: %r\n' % (tempname, msg)) return 1 rep(filename + ': updating\n') g.write(fixed) @@ -123,17 +123,17 @@ def fix(filename): statbuf = os.stat(filename) os.chmod(tempname, statbuf[ST_MODE] & 07777) except os.error, msg: - err(tempname + ': warning: chmod failed (' + `msg` + ')\n') + err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ try: os.rename(filename, filename + '~') except os.error, msg: - err(filename + ': warning: backup failed (' + `msg` + ')\n') + err('%s: warning: backup failed (%r)\n' % (filename, msg)) # Now move the temp file to the original file try: os.rename(tempname, filename) except os.error, msg: - err(filename + ': rename failed (' + `msg` + ')\n') + err('%s: rename failed (%r)\n' % (filename, msg)) return 1 # Return succes return 0 diff --git a/Tools/scripts/redemo.py b/Tools/scripts/redemo.py index 1eed8f8..de7f3c4 100644 --- a/Tools/scripts/redemo.py +++ b/Tools/scripts/redemo.py @@ -146,7 +146,7 @@ class ReDemo: groups = list(m.groups()) groups.insert(0, m.group()) for i in range(len(groups)): - g = "%2d: %s" % (i, `groups[i]`) + g = "%2d: %r" % (i, groups[i]) self.grouplist.insert(END, g) nmatches = nmatches + 1 if self.showvar.get() == "first": diff --git a/Tools/scripts/suff.py b/Tools/scripts/suff.py index ee7499f..dfb3da0 100755 --- a/Tools/scripts/suff.py +++ b/Tools/scripts/suff.py @@ -17,7 +17,7 @@ def main(): keys = suffixes.keys() keys.sort() for suff in keys: - print `suff`, len(suffixes[suff]) + print repr(suff), len(suffixes[suff]) def getsuffix(filename): suff = '' diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py index b91a53d..1d9a21a 100755 --- a/Tools/scripts/texi2html.py +++ b/Tools/scripts/texi2html.py @@ -257,7 +257,7 @@ class TexinfoParser: line = fp.readline() lineno = lineno + 1 if line[:len(MAGIC)] <> MAGIC: - raise SyntaxError, 'file does not begin with '+`MAGIC` + raise SyntaxError, 'file does not begin with %r' % (MAGIC,) self.parserest(fp, lineno) # Parse the contents of a file, not expecting a MAGIC header @@ -475,7 +475,7 @@ class TexinfoParser: continue if c <> '@': # Cannot happen unless spprog is changed - raise RuntimeError, 'unexpected funny '+`c` + raise RuntimeError, 'unexpected funny %r' % c start = i while i < n and text[i] in string.ascii_letters: i = i+1 if i == start: @@ -555,9 +555,9 @@ class TexinfoParser: try: fp = open(file, 'r') except IOError, msg: - print '*** Can\'t open include file', `file` + print '*** Can\'t open include file', repr(file) return - print '!'*self.debugging, '--> file', `file` + print '!'*self.debugging, '--> file', repr(file) save_done = self.done save_skip = self.skip save_stack = self.stack @@ -568,7 +568,7 @@ class TexinfoParser: self.done = save_done self.skip = save_skip self.stack = save_stack - print '!'*self.debugging, '<-- file', `file` + print '!'*self.debugging, '<-- file', repr(file) # --- Special Insertions --- @@ -806,7 +806,7 @@ class TexinfoParser: # if self.savetext <> None: # print '*** Recursive footnote -- expect weirdness' id = len(self.footnotes) + 1 - self.write(self.FN_SOURCE_PATTERN % {'id': `id`}) + self.write(self.FN_SOURCE_PATTERN % {'id': repr(id)) self.startsaving() def close_footnote(self): @@ -817,7 +817,7 @@ class TexinfoParser: self.write(self.FN_HEADER) for id, text in self.footnotes: self.write(self.FN_TARGET_PATTERN - % {'id': `id`, 'text': text}) + % {'id': repr(id), 'text': text}) self.footnotes = [] def open_file(self): self.write('<CODE>') @@ -1162,7 +1162,7 @@ class TexinfoParser: self.numbering[level] = self.numbering[level] + 1 x = '' for i in self.numbering: - x = x + `i` + '.' + x = x + repr(i) + '.' args = x + ' ' + args self.contents.append((level, args, self.nodename)) self.write('<', type, '>') @@ -1549,7 +1549,7 @@ class TexinfoParser: if self.whichindex.has_key(name): self.index(name, args) else: - print '*** No index named', `name` + print '*** No index named', repr(name) def do_cindex(self, args): self.index('cp', args) def do_findex(self, args): self.index('fn', args) @@ -1585,7 +1585,7 @@ class TexinfoParser: if self.whichindex.has_key(name): self.prindex(name) else: - print '*** No index named', `name` + print '*** No index named', repr(name) def prindex(self, name): iscodeindex = (name not in self.noncodeindices) diff --git a/Tools/scripts/untabify.py b/Tools/scripts/untabify.py index 17e9166..9bdf235 100755 --- a/Tools/scripts/untabify.py +++ b/Tools/scripts/untabify.py @@ -29,7 +29,7 @@ def process(filename, tabsize): text = f.read() f.close() except IOError, msg: - print "%s: I/O error: %s" % (`filename`, str(msg)) + print "%r: I/O error: %s" % (filename, msg) return newtext = text.expandtabs(tabsize) if newtext == text: diff --git a/Tools/scripts/which.py b/Tools/scripts/which.py index 2182546..7b3d2e0 100755 --- a/Tools/scripts/which.py +++ b/Tools/scripts/which.py @@ -48,7 +48,7 @@ for prog in sys.argv[1:]: msg(filename + ': not executable') if longlist: sts = os.system('ls ' + longlist + ' ' + filename) - if sts: msg('"ls -l" exit status: ' + `sts`) + if sts: msg('"ls -l" exit status: ' + repr(sts)) if not ident: msg(prog + ': not found') sts = 1 |