Kaydet (Commit) 8efadf5d authored tarafından Georg Brandl's avatar Georg Brandl

Ran 2to3 over scripts directory.

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