Fix most trivially-findable print statements.

There's one major and one minor category still unfixed:
doctests are the major category (and I hope to be able to augment the
refactoring tool to refactor bona fide doctests soon);
other code generating print statements in strings is the minor category.

(Oh, and I don't know if the compiler package works.)
This commit is contained in:
Guido van Rossum 2007-02-09 05:37:30 +00:00
parent 452bf519a7
commit be19ed77dd
331 changed files with 2567 additions and 2648 deletions

View file

@ -377,7 +377,7 @@ class ZipFile:
if not endrec:
raise BadZipfile, "File is not a zip file"
if self.debug > 1:
print endrec
print(endrec)
size_cd = endrec[5] # bytes in central directory
offset_cd = endrec[6] # offset of central directory
self.comment = endrec[8] # archive comment
@ -389,7 +389,7 @@ class ZipFile:
# "concat" is zero, unless zip was concatenated to another file
concat = x - offset_cd
if self.debug > 2:
print "given, inferred, offset", offset_cd, x, concat
print("given, inferred, offset", offset_cd, x, concat)
# self.start_dir: Position of start of central directory
self.start_dir = offset_cd + concat
fp.seek(self.start_dir, 0)
@ -403,7 +403,7 @@ class ZipFile:
raise BadZipfile, "Bad magic number for central directory"
centdir = struct.unpack(structCentralDir, centdir)
if self.debug > 2:
print centdir
print(centdir)
filename = fp.read(centdir[_CD_FILENAME_LENGTH])
# Create ZipInfo instance to store file information
x = ZipInfo(filename)
@ -426,7 +426,7 @@ class ZipFile:
self.filelist.append(x)
self.NameToInfo[x.filename] = x
if self.debug > 2:
print "total", total
print("total", total)
def namelist(self):
@ -443,10 +443,10 @@ class ZipFile:
def printdir(self):
"""Print a table of contents for the zip file."""
print "%-46s %19s %12s" % ("File Name", "Modified ", "Size")
print("%-46s %19s %12s" % ("File Name", "Modified ", "Size"))
for zinfo in self.filelist:
date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time
print "%-46s %s %12d" % (zinfo.filename, date, zinfo.file_size)
print("%-46s %s %12d" % (zinfo.filename, date, zinfo.file_size))
def testzip(self):
"""Read all the files and check the CRC."""
@ -516,7 +516,7 @@ class ZipFile:
"""Check for errors before writing a file to the archive."""
if zinfo.filename in self.NameToInfo:
if self.debug: # Warning for duplicate names
print "Duplicate name:", zinfo.filename
print("Duplicate name:", zinfo.filename)
if self.mode not in ("w", "a"):
raise RuntimeError, 'write() requires mode "w" or "a"'
if not self.fp:
@ -749,10 +749,10 @@ class PyZipFile(ZipFile):
else:
basename = name
if self.debug:
print "Adding package in", pathname, "as", basename
print("Adding package in", pathname, "as", basename)
fname, arcname = self._get_codename(initname[0:-3], basename)
if self.debug:
print "Adding", arcname
print("Adding", arcname)
self.write(fname, arcname)
dirlist = os.listdir(pathname)
dirlist.remove("__init__.py")
@ -768,12 +768,12 @@ class PyZipFile(ZipFile):
fname, arcname = self._get_codename(path[0:-3],
basename)
if self.debug:
print "Adding", arcname
print("Adding", arcname)
self.write(fname, arcname)
else:
# This is NOT a package directory, add its files at top level
if self.debug:
print "Adding files from directory", pathname
print("Adding files from directory", pathname)
for filename in os.listdir(pathname):
path = os.path.join(pathname, filename)
root, ext = os.path.splitext(filename)
@ -781,7 +781,7 @@ class PyZipFile(ZipFile):
fname, arcname = self._get_codename(path[0:-3],
basename)
if self.debug:
print "Adding", arcname
print("Adding", arcname)
self.write(fname, arcname)
else:
if pathname[-3:] != ".py":
@ -789,7 +789,7 @@ class PyZipFile(ZipFile):
'Files added with writepy() must end with ".py"'
fname, arcname = self._get_codename(pathname[0:-3], basename)
if self.debug:
print "Adding file", arcname
print("Adding file", arcname)
self.write(fname, arcname)
def _get_codename(self, pathname, basename):
@ -809,11 +809,11 @@ class PyZipFile(ZipFile):
os.stat(file_pyc).st_mtime < os.stat(file_py).st_mtime:
import py_compile
if self.debug:
print "Compiling", file_py
print("Compiling", file_py)
try:
py_compile.compile(file_py, file_pyc, None, True)
except py_compile.PyCompileError as err:
print err.msg
print(err.msg)
fname = file_pyc
else:
fname = file_pyc
@ -836,12 +836,12 @@ def main(args = None):
args = sys.argv[1:]
if not args or args[0] not in ('-l', '-c', '-e', '-t'):
print USAGE
print(USAGE)
sys.exit(1)
if args[0] == '-l':
if len(args) != 2:
print USAGE
print(USAGE)
sys.exit(1)
zf = ZipFile(args[1], 'r')
zf.printdir()
@ -849,15 +849,15 @@ def main(args = None):
elif args[0] == '-t':
if len(args) != 2:
print USAGE
print(USAGE)
sys.exit(1)
zf = ZipFile(args[1], 'r')
zf.testzip()
print "Done testing"
print("Done testing")
elif args[0] == '-e':
if len(args) != 3:
print USAGE
print(USAGE)
sys.exit(1)
zf = ZipFile(args[1], 'r')
@ -878,7 +878,7 @@ def main(args = None):
elif args[0] == '-c':
if len(args) < 3:
print USAGE
print(USAGE)
sys.exit(1)
def addToZip(zf, path, zippath):