mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Run 2to3 over the Demo/ directory to shut up parse errors from 2to3 about lingering print statements.
This commit is contained in:
parent
a8c360ee76
commit
6f2df4d5e1
132 changed files with 1070 additions and 1080 deletions
|
|
@ -26,8 +26,8 @@ def main():
|
|||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'm:s:')
|
||||
except getopt.error as msg:
|
||||
print msg
|
||||
print 'usage: ftpstats [-m maxitems] [file]'
|
||||
print(msg)
|
||||
print('usage: ftpstats [-m maxitems] [file]')
|
||||
sys.exit(2)
|
||||
for o, a in opts:
|
||||
if o == '-m':
|
||||
|
|
@ -42,7 +42,7 @@ def main():
|
|||
try:
|
||||
f = open(file, 'r')
|
||||
except IOError as msg:
|
||||
print file, ':', msg
|
||||
print(file, ':', msg)
|
||||
sys.exit(1)
|
||||
bydate = {}
|
||||
bytime = {}
|
||||
|
|
@ -60,7 +60,7 @@ def main():
|
|||
if search and string.find(line, search) < 0:
|
||||
continue
|
||||
if prog.match(line) < 0:
|
||||
print 'Bad line', lineno, ':', repr(line)
|
||||
print('Bad line', lineno, ':', repr(line))
|
||||
continue
|
||||
items = prog.group(1, 2, 3, 4, 5, 6)
|
||||
(logtime, loguser, loghost, logfile, logbytes,
|
||||
|
|
@ -93,7 +93,7 @@ def main():
|
|||
add(byuser, loguser, items)
|
||||
add(bytype, direction, items)
|
||||
except KeyboardInterrupt:
|
||||
print 'Interrupted at line', lineno
|
||||
print('Interrupted at line', lineno)
|
||||
show(bytype, 'by transfer direction', maxitems)
|
||||
show(bydir, 'by directory', maxitems)
|
||||
show(byfile, 'by file', maxitems)
|
||||
|
|
@ -104,9 +104,9 @@ def main():
|
|||
|
||||
def showbar(dict, title):
|
||||
n = len(title)
|
||||
print '='*((70-n)/2), title, '='*((71-n)/2)
|
||||
print('='*((70-n)/2), title, '='*((71-n)/2))
|
||||
list = []
|
||||
keys = dict.keys()
|
||||
keys = list(dict.keys())
|
||||
keys.sort()
|
||||
for key in keys:
|
||||
n = len(str(key))
|
||||
|
|
@ -120,23 +120,23 @@ def showbar(dict, title):
|
|||
for count, key in list:
|
||||
barlength = int(round(maxbarlength*float(count)/maxcount))
|
||||
bar = '*'*barlength
|
||||
print '%5d %-*s %s' % (count, maxkeylength, key, bar)
|
||||
print('%5d %-*s %s' % (count, maxkeylength, key, bar))
|
||||
|
||||
def show(dict, title, maxitems):
|
||||
if len(dict) > maxitems:
|
||||
title = title + ' (first %d)'%maxitems
|
||||
n = len(title)
|
||||
print '='*((70-n)/2), title, '='*((71-n)/2)
|
||||
print('='*((70-n)/2), title, '='*((71-n)/2))
|
||||
list = []
|
||||
keys = dict.keys()
|
||||
keys = list(dict.keys())
|
||||
for key in keys:
|
||||
list.append((-len(dict[key]), key))
|
||||
list.sort()
|
||||
for count, key in list[:maxitems]:
|
||||
print '%5d %s' % (-count, key)
|
||||
print('%5d %s' % (-count, key))
|
||||
|
||||
def add(dict, key, item):
|
||||
if dict.has_key(key):
|
||||
if key in dict:
|
||||
dict[key].append(item)
|
||||
else:
|
||||
dict[key] = [item]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue