summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-09-29 20:44:48 (GMT)
committerFred Drake <fdrake@acm.org>2000-09-29 20:44:48 (GMT)
commit5db246d1fa8e8fe89d544cdb26bc15af558e15a1 (patch)
tree864e6b212e0dfd07d3516491cb1078f978ac46fa /Lib/zipfile.py
parenta77254a724e630cddc7c2c71f8c931d4daf0ee7d (diff)
downloadcpython-5db246d1fa8e8fe89d544cdb26bc15af558e15a1.zip
cpython-5db246d1fa8e8fe89d544cdb26bc15af558e15a1.tar.gz
cpython-5db246d1fa8e8fe89d544cdb26bc15af558e15a1.tar.bz2
Always use the same name for the exception defined in this module!
Error reported via email by Pete Shinners <pete@visionart.com>. Fixed some indentation inconsistencies.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index dfcf72f..7dab238 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -10,9 +10,9 @@ try:
except:
zlib = None
-class _BadZipfile(Exception):
+class BadZipfile(Exception):
pass
-error = _BadZipfile # The exception raised by this module
+error = BadZipfile # The exception raised by this module
# constants for Zip file compression methods
ZIP_STORED = 0
@@ -94,7 +94,7 @@ class ZipFile:
elif compression == ZIP_DEFLATED:
if not zlib:
raise RuntimeError,\
- "Compression requires the (missing) zlib module"
+ "Compression requires the (missing) zlib module"
else:
raise RuntimeError, "That compression method is not supported"
self.debug = 0 # Level of printing: 0 through 3
@@ -180,8 +180,8 @@ class ZipFile:
fname = fp.read(fheader[10])
if fname != data.filename:
raise RuntimeError, \
- 'File name in Central Directory "%s" and File Header "%s" differ.' % (
- data.filename, fname)
+ 'File name in directory "%s" and header "%s" differ.' % (
+ data.filename, fname)
def namelist(self):
"Return a list of file names in the archive"
@@ -219,7 +219,7 @@ class ZipFile:
raise RuntimeError, 'read() requires mode "r" or "a"'
if not self.fp:
raise RuntimeError, \
- "Attempt to read ZIP archive that was already closed"
+ "Attempt to read ZIP archive that was already closed"
zinfo = self.getinfo(name)
filepos = self.fp.tell()
self.fp.seek(zinfo.file_offset, 0)
@@ -230,7 +230,7 @@ class ZipFile:
elif zinfo.compress_type == ZIP_DEFLATED:
if not zlib:
raise RuntimeError, \
- "De-compression requires the (missing) zlib module"
+ "De-compression requires the (missing) zlib module"
# zlib compress/decompress code by Jeremy Hylton of CNRI
dc = zlib.decompressobj(-15)
bytes = dc.decompress(bytes)
@@ -240,7 +240,7 @@ class ZipFile:
bytes = bytes + ex
else:
raise BadZipfile, \
- "Unsupported compression method %d for file %s" % \
+ "Unsupported compression method %d for file %s" % \
(zinfo.compress_type, name)
crc = binascii.crc32(bytes)
if crc != zinfo.CRC:
@@ -256,13 +256,13 @@ class ZipFile:
raise RuntimeError, 'write() requires mode "w" or "a"'
if not self.fp:
raise RuntimeError, \
- "Attempt to write ZIP archive that was already closed"
+ "Attempt to write ZIP archive that was already closed"
if zinfo.compress_type == ZIP_DEFLATED and not zlib:
raise RuntimeError, \
- "Compression requires the (missing) zlib module"
+ "Compression requires the (missing) zlib module"
if zinfo.compress_type not in (ZIP_STORED, ZIP_DEFLATED):
raise RuntimeError, \
- "That compression method is not supported"
+ "That compression method is not supported"
def write(self, filename, arcname=None, compress_type=None):
'Put the bytes from filename into the archive under the name arcname.'
@@ -437,7 +437,7 @@ This method will compile the module.py into module.pyc if necessary."""
else:
if pathname[-3:] != ".py":
raise RuntimeError, \
- 'Files added with writepy() must end with ".py"'
+ 'Files added with writepy() must end with ".py"'
fname, arcname = self._get_codename(pathname[0:-3], basename)
if self.debug:
print "Adding file", arcname