summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xTools/scripts/checkpyc.py6
-rwxr-xr-xTools/scripts/copytime.py2
-rwxr-xr-xTools/scripts/findnocoding.py2
-rwxr-xr-xTools/scripts/fixcid.py4
-rwxr-xr-xTools/scripts/fixdiv.py2
-rwxr-xr-xTools/scripts/fixheader.py2
-rwxr-xr-xTools/scripts/ftpmirror.py8
-rwxr-xr-xTools/scripts/h2py.py6
-rwxr-xr-xTools/scripts/mailerdaemon.py4
-rwxr-xr-xTools/scripts/nm2def.py2
-rwxr-xr-xTools/scripts/objgraph.py27
-rwxr-xr-xTools/scripts/parseentities.py5
-rwxr-xr-xTools/scripts/pdeps.py10
-rw-r--r--Tools/scripts/pickle2db.py2
-rwxr-xr-xTools/scripts/pindent.py4
-rwxr-xr-xTools/scripts/suff.py5
-rwxr-xr-xTools/scripts/texi2html.py65
-rwxr-xr-xTools/scripts/treesync.py2
-rwxr-xr-xTools/scripts/xxci.py2
19 files changed, 74 insertions, 86 deletions
diff --git a/Tools/scripts/checkpyc.py b/Tools/scripts/checkpyc.py
index a38bc45..2e8fd5a 100755
--- a/Tools/scripts/checkpyc.py
+++ b/Tools/scripts/checkpyc.py
@@ -46,19 +46,19 @@ def main():
magic_str = f.read(4)
mtime_str = f.read(4)
f.close()
- if magic_str <> MAGIC:
+ if magic_str != MAGIC:
print('Bad MAGIC word in ".pyc" file', end=' ')
print(repr(name_c))
continue
mtime = get_long(mtime_str)
if mtime == 0 or mtime == -1:
print('Bad ".pyc" file', repr(name_c))
- elif mtime <> st[ST_MTIME]:
+ elif mtime != st[ST_MTIME]:
print('Out-of-date ".pyc" file', end=' ')
print(repr(name_c))
def get_long(s):
- if len(s) <> 4:
+ if len(s) != 4:
return -1
return ord(s[0]) + (ord(s[1])<<8) + (ord(s[2])<<16) + (ord(s[3])<<24)
diff --git a/Tools/scripts/copytime.py b/Tools/scripts/copytime.py
index 209c492..ba4a267 100755
--- a/Tools/scripts/copytime.py
+++ b/Tools/scripts/copytime.py
@@ -7,7 +7,7 @@ import os
from stat import ST_ATIME, ST_MTIME # Really constants 7 and 8
def main():
- if len(sys.argv) <> 3:
+ if len(sys.argv) != 3:
sys.stderr.write('usage: copytime source destination\n')
sys.exit(2)
file1, file2 = sys.argv[1], sys.argv[2]
diff --git a/Tools/scripts/findnocoding.py b/Tools/scripts/findnocoding.py
index ade4390..a049c0f 100755
--- a/Tools/scripts/findnocoding.py
+++ b/Tools/scripts/findnocoding.py
@@ -42,7 +42,7 @@ def get_declaration(line):
def has_correct_encoding(text, codec):
try:
- unicode(text, codec)
+ str(text, codec)
except UnicodeDecodeError:
return False
else:
diff --git a/Tools/scripts/fixcid.py b/Tools/scripts/fixcid.py
index 1235e4f..c9d3a29 100755
--- a/Tools/scripts/fixcid.py
+++ b/Tools/scripts/fixcid.py
@@ -240,7 +240,7 @@ def fixline(line):
elif found == '*/':
Program = OutsideCommentProgram
n = len(found)
- if Dict.has_key(found):
+ if found in Dict:
subst = Dict[found]
if Program is InsideCommentProgram:
if not Docomments:
@@ -304,7 +304,7 @@ def addsubst(substfile):
if key[0] == '*':
key = key[1:]
NotInComment[key] = value
- if Dict.has_key(key):
+ if key in Dict:
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
diff --git a/Tools/scripts/fixdiv.py b/Tools/scripts/fixdiv.py
index a4b4f21..8b15cc6 100755
--- a/Tools/scripts/fixdiv.py
+++ b/Tools/scripts/fixdiv.py
@@ -158,7 +158,7 @@ def main():
warnings = readwarnings(args[0])
if warnings is None:
return 1
- files = warnings.keys()
+ files = list(warnings.keys())
if not files:
print("No classic division warnings read from", args[0])
return
diff --git a/Tools/scripts/fixheader.py b/Tools/scripts/fixheader.py
index 7231829..1208031 100755
--- a/Tools/scripts/fixheader.py
+++ b/Tools/scripts/fixheader.py
@@ -17,7 +17,7 @@ def process(filename):
return
data = f.read()
f.close()
- if data[:2] <> '/*':
+ if data[:2] != '/*':
sys.stderr.write('%s does not begin with C comment\n' % filename)
return
try:
diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py
index dd941a5..b79db1a 100755
--- a/Tools/scripts/ftpmirror.py
+++ b/Tools/scripts/ftpmirror.py
@@ -169,7 +169,7 @@ def mirrorsubdir(f, localdir):
subdirs.append(filename)
continue
filesfound.append(filename)
- if info.has_key(filename) and info[filename] == infostuff:
+ if filename in info and info[filename] == infostuff:
if verbose > 1:
print('Already have this version of',repr(filename))
continue
@@ -178,7 +178,7 @@ def mirrorsubdir(f, localdir):
if interactive:
doit = askabout('file', filename, pwd)
if not doit:
- if not info.has_key(filename):
+ if filename not in info:
info[filename] = 'Not retrieved'
continue
try:
@@ -241,7 +241,7 @@ def mirrorsubdir(f, localdir):
#
# Remove files from info that are no longer remote
deletions = 0
- for filename in info.keys():
+ for filename in list(info.keys()):
if filename not in filesfound:
if verbose:
print("Removing obsolete info entry for", end=' ')
@@ -258,7 +258,7 @@ def mirrorsubdir(f, localdir):
except os.error:
names = []
for name in names:
- if name[0] == '.' or info.has_key(name) or name in subdirs:
+ if name[0] == '.' or name in info or name in subdirs:
continue
skip = 0
for pat in skippats:
diff --git a/Tools/scripts/h2py.py b/Tools/scripts/h2py.py
index 58acb82..19995b9 100755
--- a/Tools/scripts/h2py.py
+++ b/Tools/scripts/h2py.py
@@ -101,7 +101,7 @@ def pytify(body):
m = p_hex.search(body, start)
if not m: break
s,e = m.span()
- val = long(body[slice(*m.span(1))], 16)
+ val = int(body[slice(*m.span(1))], 16)
if val > sys.maxsize:
val -= UMAX
body = body[:s] + "(" + str(val) + ")" + body[e:]
@@ -150,9 +150,9 @@ def process(fp, outfp, env = {}):
regs = match.regs
a, b = regs[1]
filename = line[a:b]
- if importable.has_key(filename):
+ if filename in importable:
outfp.write('from %s import *\n' % importable[filename])
- elif not filedict.has_key(filename):
+ elif filename not in filedict:
filedict[filename] = None
inclfp = None
for dir in searchdirs:
diff --git a/Tools/scripts/mailerdaemon.py b/Tools/scripts/mailerdaemon.py
index e6ea633..6e3fda8 100755
--- a/Tools/scripts/mailerdaemon.py
+++ b/Tools/scripts/mailerdaemon.py
@@ -163,7 +163,7 @@ def parsedir(dir, modify):
nok = nwarn = nbad = 0
# find all numeric file names and sort them
- files = filter(lambda fn, pat=pat: pat.match(fn) is not None, os.listdir('.'))
+ files = list(filter(lambda fn, pat=pat: pat.match(fn) is not None, os.listdir('.')))
files.sort(sort_numeric)
for fn in files:
@@ -198,7 +198,7 @@ def parsedir(dir, modify):
date = '%s %02d' % (calendar.month_abbr[mm], dd)
except:
date = '??????'
- if not errordict.has_key(e):
+ if e not in errordict:
errordict[e] = 1
errorfirst[e] = '%s (%s)' % (fn, date)
else:
diff --git a/Tools/scripts/nm2def.py b/Tools/scripts/nm2def.py
index 5f2bc8f..9dfb991 100755
--- a/Tools/scripts/nm2def.py
+++ b/Tools/scripts/nm2def.py
@@ -84,7 +84,7 @@ SPECIALS = (
def filter_Python(symbols,specials=SPECIALS):
- for name in symbols.keys():
+ for name in list(symbols.keys()):
if name[:2] == 'Py' or name[:3] == '_Py':
pass
elif name not in specials:
diff --git a/Tools/scripts/objgraph.py b/Tools/scripts/objgraph.py
index 85e6a69..0975a3b 100755
--- a/Tools/scripts/objgraph.py
+++ b/Tools/scripts/objgraph.py
@@ -39,7 +39,7 @@ matcher = re.compile('(.*):\t?........ (.) (.*)$')
# If there is no list for the key yet, it is created.
#
def store(dict, key, item):
- if dict.has_key(key):
+ if key in dict:
dict[key].append(item)
else:
dict[key] = [item]
@@ -86,8 +86,7 @@ def readinput(fp):
# defined.
#
def printcallee():
- flist = file2undef.keys()
- flist.sort()
+ flist = sorted(file2undef.keys())
for filename in flist:
print(filename + ':')
elist = file2undef[filename]
@@ -97,7 +96,7 @@ def printcallee():
tabs = '\t'
else:
tabs = '\t\t'
- if not def2file.has_key(ext):
+ if ext not in def2file:
print('\t' + ext + tabs + ' *undefined')
else:
print('\t' + ext + tabs + flat(def2file[ext]))
@@ -105,19 +104,18 @@ def printcallee():
# Print for each module the names of the other modules that use it.
#
def printcaller():
- files = file2def.keys()
- files.sort()
+ files = sorted(file2def.keys())
for filename in files:
callers = []
for label in file2def[filename]:
- if undef2file.has_key(label):
+ if label in undef2file:
callers = callers + undef2file[label]
if callers:
callers.sort()
print(filename + ':')
lastfn = ''
for fn in callers:
- if fn <> lastfn:
+ if fn != lastfn:
print('\t' + fn)
lastfn = fn
else:
@@ -127,16 +125,14 @@ def printcaller():
#
def printundef():
undefs = {}
- for filename in file2undef.keys():
+ for filename in list(file2undef.keys()):
for ext in file2undef[filename]:
- if not def2file.has_key(ext):
+ if ext not in def2file:
store(undefs, ext, filename)
- elist = undefs.keys()
- elist.sort()
+ elist = sorted(undefs.keys())
for ext in elist:
print(ext + ':')
- flist = undefs[ext]
- flist.sort()
+ flist = sorted(undefs[ext])
for filename in flist:
print('\t' + filename)
@@ -145,8 +141,7 @@ def printundef():
def warndups():
savestdout = sys.stdout
sys.stdout = sys.stderr
- names = def2file.keys()
- names.sort()
+ names = sorted(def2file.keys())
for name in names:
if len(def2file[name]) > 1:
print('warning:', name, 'multiply defined:', end=' ')
diff --git a/Tools/scripts/parseentities.py b/Tools/scripts/parseentities.py
index cf4e17c..8d93167 100755
--- a/Tools/scripts/parseentities.py
+++ b/Tools/scripts/parseentities.py
@@ -35,9 +35,8 @@ def parse(text,pos=0,endpos=None):
def writefile(f,defs):
f.write("entitydefs = {\n")
- items = defs.items()
- items.sort()
- for name,(charcode,comment) in items:
+ items = sorted(defs.items())
+ for name, (charcode,comment) in items:
if charcode[:2] == '&#':
code = int(charcode[2:-1])
if code < 256:
diff --git a/Tools/scripts/pdeps.py b/Tools/scripts/pdeps.py
index 35b4067..5c5a05b 100755
--- a/Tools/scripts/pdeps.py
+++ b/Tools/scripts/pdeps.py
@@ -92,7 +92,7 @@ def process(filename, table):
# Compute closure (this is in fact totally general)
#
def closure(table):
- modules = table.keys()
+ modules = list(table.keys())
#
# Initialize reach with a copy of table
#
@@ -135,7 +135,7 @@ def inverse(table):
# If there is no list for the key yet, it is created.
#
def store(dict, key, item):
- if dict.has_key(key):
+ if key in dict:
dict[key].append(item)
else:
dict[key] = [item]
@@ -144,13 +144,11 @@ def store(dict, key, item):
# Tabulate results neatly
#
def printresults(table):
- modules = table.keys()
+ modules = sorted(table.keys())
maxlen = 0
for mod in modules: maxlen = max(maxlen, len(mod))
- modules.sort()
for mod in modules:
- list = table[mod]
- list.sort()
+ list = sorted(table[mod])
print(mod.ljust(maxlen), ':', end=' ')
if mod in list:
print('(*)', end=' ')
diff --git a/Tools/scripts/pickle2db.py b/Tools/scripts/pickle2db.py
index 86545cc..c66f5e9 100644
--- a/Tools/scripts/pickle2db.py
+++ b/Tools/scripts/pickle2db.py
@@ -128,7 +128,7 @@ def main(args):
sys.stderr.write("Check for format or version mismatch.\n")
return 1
else:
- for k in db.keys():
+ for k in list(db.keys()):
del db[k]
while 1:
diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py
index 3ea1a52..3f3000d 100755
--- a/Tools/scripts/pindent.py
+++ b/Tools/scripts/pindent.py
@@ -188,7 +188,7 @@ class PythonIndenter:
stack.append((kw, kw))
continue
# end if
- if next.has_key(kw) and stack:
+ if kw in next and stack:
self.putline(line, len(stack)-1)
kwa, kwb = stack[-1]
stack[-1] = kwa, kw
@@ -254,7 +254,7 @@ class PythonIndenter:
m = self.kwprog.match(line)
if m:
thiskw = m.group('kw')
- if not next.has_key(thiskw):
+ if thiskw not in next:
thiskw = ''
# end if
if thiskw in ('def', 'class'):
diff --git a/Tools/scripts/suff.py b/Tools/scripts/suff.py
index 8fbdbc2..462ec32 100755
--- a/Tools/scripts/suff.py
+++ b/Tools/scripts/suff.py
@@ -11,11 +11,10 @@ def main():
suffixes = {}
for filename in files:
suff = getsuffix(filename)
- if not suffixes.has_key(suff):
+ if suff not in suffixes:
suffixes[suff] = []
suffixes[suff].append(filename)
- keys = suffixes.keys()
- keys.sort()
+ keys = sorted(suffixes.keys())
for suff in keys:
print(repr(suff), len(suffixes[suff]))
diff --git a/Tools/scripts/texi2html.py b/Tools/scripts/texi2html.py
index eae466c..9fd1f7b 100755
--- a/Tools/scripts/texi2html.py
+++ b/Tools/scripts/texi2html.py
@@ -114,7 +114,8 @@ class HTMLNode:
self.lines = []
def write(self, *lines):
- map(self.lines.append, lines)
+ for line in lines:
+ self.lines.append(line)
def flush(self):
fp = open(self.dirname + '/' + makefile(self.name), 'w')
@@ -173,7 +174,7 @@ class HTMLNode:
self.link(' Next', self.next, rel='Next')
self.link(' Prev', self.prev, rel='Previous')
self.link(' Up', self.up, rel='Up')
- if self.name <> self.topname:
+ if self.name != self.topname:
self.link(' Top', self.topname)
@@ -256,7 +257,7 @@ class TexinfoParser:
while line and (line[0] == '%' or blprog.match(line)):
line = fp.readline()
lineno = lineno + 1
- if line[:len(MAGIC)] <> MAGIC:
+ if line[:len(MAGIC)] != MAGIC:
raise SyntaxError('file does not begin with %r' % (MAGIC,))
self.parserest(fp, lineno)
@@ -318,7 +319,7 @@ class TexinfoParser:
# Start saving text in a buffer instead of writing it to a file
def startsaving(self):
- if self.savetext <> None:
+ if self.savetext != None:
self.savestack.append(self.savetext)
# print '*** Recursively saving text, expect trouble'
self.savetext = ''
@@ -340,7 +341,7 @@ class TexinfoParser:
except:
print(args)
raise TypeError
- if self.savetext <> None:
+ if self.savetext != None:
self.savetext = self.savetext + text
elif self.nodefp:
self.nodefp.write(text)
@@ -349,7 +350,7 @@ class TexinfoParser:
# Complete the current node -- write footnotes and close file
def endnode(self):
- if self.savetext <> None:
+ if self.savetext != None:
print('*** Still saving text at end of node')
dummy = self.collectsavings()
if self.footnotes:
@@ -361,7 +362,7 @@ class TexinfoParser:
self.link('Next', next)
self.link('Prev', prev)
self.link('Up', up)
- if self.nodename <> self.topname:
+ if self.nodename != self.topname:
self.link('Top', self.topname)
self.write('<HR>\n')
self.write('</BODY>\n')
@@ -473,7 +474,7 @@ class TexinfoParser:
continue
method()
continue
- if c <> '@':
+ if c != '@':
# Cannot happen unless spprog is changed
raise RuntimeError('unexpected funny %r' % c)
start = i
@@ -517,7 +518,7 @@ class TexinfoParser:
print('*** No open func for @' + cmd + '{...}')
cmd = cmd + '{'
self.write('@', cmd)
- if not self.unknown.has_key(cmd):
+ if cmd not in self.unknown:
self.unknown[cmd] = 1
else:
self.unknown[cmd] = self.unknown[cmd] + 1
@@ -526,7 +527,7 @@ class TexinfoParser:
print('*** No close func for @' + cmd + '{...}')
cmd = '}' + cmd
self.write('}')
- if not self.unknown.has_key(cmd):
+ if cmd not in self.unknown:
self.unknown[cmd] = 1
else:
self.unknown[cmd] = self.unknown[cmd] + 1
@@ -534,7 +535,7 @@ class TexinfoParser:
def unknown_handle(self, cmd):
print('*** No handler for @' + cmd)
self.write('@', cmd)
- if not self.unknown.has_key(cmd):
+ if cmd not in self.unknown:
self.unknown[cmd] = 1
else:
self.unknown[cmd] = self.unknown[cmd] + 1
@@ -891,7 +892,7 @@ class TexinfoParser:
def unknown_cmd(self, cmd, args):
print('*** unknown', '@' + cmd, args)
- if not self.unknown.has_key(cmd):
+ if cmd not in self.unknown:
self.unknown[cmd] = 1
else:
self.unknown[cmd] = self.unknown[cmd] + 1
@@ -902,7 +903,7 @@ class TexinfoParser:
print('*** @end w/o args')
else:
cmd = words[0]
- if not self.stack or self.stack[-1] <> cmd:
+ if not self.stack or self.stack[-1] != cmd:
print('*** @end', cmd, 'unexpected')
else:
del self.stack[-1]
@@ -916,7 +917,7 @@ class TexinfoParser:
def unknown_end(self, cmd):
cmd = 'end ' + cmd
print('*** unknown', '@' + cmd)
- if not self.unknown.has_key(cmd):
+ if cmd not in self.unknown:
self.unknown[cmd] = 1
else:
self.unknown[cmd] = self.unknown[cmd] + 1
@@ -953,8 +954,7 @@ class TexinfoParser:
self.values[args] = None
def bgn_ifset(self, args):
- if args not in self.values.keys() \
- or self.values[args] is None:
+ if args not in self.values or self.values[args] is None:
self.skip = self.skip + 1
self.stackinfo[len(self.stack)] = 1
else:
@@ -968,8 +968,7 @@ class TexinfoParser:
print('*** end_ifset: KeyError :', len(self.stack) + 1)
def bgn_ifclear(self, args):
- if args in self.values.keys() \
- and self.values[args] is not None:
+ if args in self.values and self.values[args] is not None:
self.skip = self.skip + 1
self.stackinfo[len(self.stack)] = 1
else:
@@ -987,7 +986,7 @@ class TexinfoParser:
def close_value(self):
key = self.collectsavings()
- if key in self.values.keys():
+ if key in self.values:
self.write(self.values[key])
else:
print('*** Undefined value: ', key)
@@ -1051,7 +1050,7 @@ class TexinfoParser:
self.nodelinks = parts
[name, next, prev, up] = parts[:4]
file = self.dirname + '/' + makefile(name)
- if self.filenames.has_key(file):
+ if file in self.filenames:
print('*** Filename already in use: ', file)
else:
if self.debugging: print('!'*self.debugging, '--- writing', file)
@@ -1443,7 +1442,7 @@ class TexinfoParser:
else:
# some other character, e.g. '-'
args = self.itemarg + ' ' + args
- if self.itemnumber <> None:
+ if self.itemnumber != None:
args = self.itemnumber + '. ' + args
self.itemnumber = increment(self.itemnumber)
if self.stack and self.stack[-1] == 'table':
@@ -1542,11 +1541,11 @@ class TexinfoParser:
self.indextitle['vr'] = 'Variable'
#
self.whichindex = {}
- for name in self.indextitle.keys():
+ for name in self.indextitle:
self.whichindex[name] = []
def user_index(self, name, args):
- if self.whichindex.has_key(name):
+ if name in self.whichindex:
self.index(name, args)
else:
print('*** No index named', repr(name))
@@ -1564,15 +1563,15 @@ class TexinfoParser:
def do_synindex(self, args):
words = args.split()
- if len(words) <> 2:
+ if len(words) != 2:
print('*** bad @synindex', args)
return
[old, new] = words
- if not self.whichindex.has_key(old) or \
- not self.whichindex.has_key(new):
+ if old not in self.whichindex or \
+ new not in self.whichindex:
print('*** bad key(s) in @synindex', args)
return
- if old <> new and \
+ if old != new and \
self.whichindex[old] is not self.whichindex[new]:
inew = self.whichindex[new]
inew[len(inew):] = self.whichindex[old]
@@ -1582,7 +1581,7 @@ class TexinfoParser:
def do_printindex(self, args):
words = args.split()
for name in words:
- if self.whichindex.has_key(name):
+ if name in self.whichindex:
self.prindex(name)
else:
print('*** No index named', repr(name))
@@ -1630,8 +1629,7 @@ class TexinfoParser:
def report(self):
if self.unknown:
print('--- Unrecognized commands ---')
- cmds = self.unknown.keys()
- cmds.sort()
+ cmds = sorted(self.unknown.keys())
for cmd in cmds:
print(cmd.ljust(20), self.unknown[cmd])
@@ -1849,8 +1847,7 @@ class HTMLHelp:
sys.exit(1)
def dumpfiles(self, outfile=sys.stdout):
- filelist = self.filenames.values()
- filelist.sort()
+ filelist = sorted(self.filenames.values())
for filename in filelist:
print(filename, file=outfile)
@@ -1872,7 +1869,7 @@ class HTMLHelp:
self.current = nodename
# Have we been dumped already?
- if self.dumped.has_key(nodename):
+ if nodename in self.dumped:
return
self.dumped[nodename] = 1
@@ -2040,7 +2037,7 @@ def test():
if sys.argv[1] == '-H':
helpbase = sys.argv[2]
del sys.argv[1:3]
- if len(sys.argv) <> 3:
+ if len(sys.argv) != 3:
print('usage: texi2hh [-d [-d]] [-p] [-c] [-3] [-H htmlhelp]', \
'inputfile outputdirectory')
sys.exit(2)
diff --git a/Tools/scripts/treesync.py b/Tools/scripts/treesync.py
index ff72c8c..8643ee7 100755
--- a/Tools/scripts/treesync.py
+++ b/Tools/scripts/treesync.py
@@ -195,7 +195,7 @@ def raw_input(prompt):
def okay(prompt, answer='ask'):
answer = answer.strip().lower()
if not answer or answer[0] not in 'ny':
- answer = raw_input(prompt)
+ answer = input(prompt)
answer = answer.strip().lower()
if not answer:
answer = default_answer
diff --git a/Tools/scripts/xxci.py b/Tools/scripts/xxci.py
index 59da43a..8cffc9e 100755
--- a/Tools/scripts/xxci.py
+++ b/Tools/scripts/xxci.py
@@ -110,7 +110,7 @@ def raw_input(prompt):
return sys.stdin.readline()
def askyesno(prompt):
- s = raw_input(prompt)
+ s = input(prompt)
return s in ['y', 'yes']
if __name__ == '__main__':