summaryrefslogtreecommitdiffstats
path: root/Lib/gzip.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-01-14 23:47:14 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-01-14 23:47:14 (GMT)
commit07e99cb77406e1bc84606f49b743e41b0de8a6d5 (patch)
treeb922cda3a970bffa797269fd550f8d8b032afe5b /Lib/gzip.py
parent88869f9787cd4ceb2298e4b13980beb057687824 (diff)
downloadcpython-07e99cb77406e1bc84606f49b743e41b0de8a6d5.zip
cpython-07e99cb77406e1bc84606f49b743e41b0de8a6d5.tar.gz
cpython-07e99cb77406e1bc84606f49b743e41b0de8a6d5.tar.bz2
Whitespace normalization.
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r--Lib/gzip.py50
1 files changed, 25 insertions, 25 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index 0c9642b..2ed3d9c 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -15,7 +15,7 @@ READ, WRITE = 1, 2
def write32(output, value):
output.write(struct.pack("<l", value))
-
+
def write32u(output, value):
output.write(struct.pack("<L", value))
@@ -29,7 +29,7 @@ class GzipFile:
myfileobj = None
- def __init__(self, filename=None, mode=None,
+ def __init__(self, filename=None, mode=None,
compresslevel=9, fileobj=None):
if fileobj is None:
fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
@@ -42,8 +42,8 @@ class GzipFile:
if mode[0:1] == 'r':
self.mode = READ
- # Set flag indicating start of a new member
- self._new_member = 1
+ # Set flag indicating start of a new member
+ self._new_member = 1
self.extrabuf = ""
self.extrasize = 0
self.filename = filename
@@ -52,7 +52,7 @@ class GzipFile:
self.mode = WRITE
self._init_write(filename)
self.compress = zlib.compressobj(compresslevel,
- zlib.DEFLATED,
+ zlib.DEFLATED,
-zlib.MAX_WBITS,
zlib.DEF_MEM_LEVEL,
0)
@@ -110,7 +110,7 @@ class GzipFile:
if flag & FEXTRA:
# Read & discard the extra field, if present
- xlen=ord(self.fileobj.read(1))
+ xlen=ord(self.fileobj.read(1))
xlen=xlen+256*ord(self.fileobj.read(1))
self.fileobj.read(xlen)
if flag & FNAME:
@@ -158,7 +158,7 @@ class GzipFile:
except EOFError:
if size > self.extrasize:
size = self.extrasize
-
+
chunk = self.extrabuf[:size]
self.extrabuf = self.extrabuf[size:]
self.extrasize = self.extrasize - size
@@ -171,11 +171,11 @@ class GzipFile:
def _read(self, size=1024):
if self.fileobj is None: raise EOFError, "Reached EOF"
-
+
if self._new_member:
# If the _new_member flag is set, we have to
# jump to the next member, if there is one.
- #
+ #
# First, check if we're at the end of the file;
# if so, it's time to stop; no more members to read.
pos = self.fileobj.tell() # Save current position
@@ -183,27 +183,27 @@ class GzipFile:
if pos == self.fileobj.tell():
self.fileobj = None
raise EOFError, "Reached EOF"
- else:
+ else:
self.fileobj.seek( pos ) # Return to original position
-
- self._init_read()
+
+ self._init_read()
self._read_gzip_header()
self.decompress = zlib.decompressobj(-zlib.MAX_WBITS)
self._new_member = 0
-
+
# Read a chunk of data from the file
buf = self.fileobj.read(size)
-
+
# If the EOF has been reached, flush the decompression object
# and mark this object as finished.
-
+
if buf == "":
uncompress = self.decompress.flush()
self._read_eof()
self.fileobj = None
self._add_read_data( uncompress )
raise EOFError, 'Reached EOF'
-
+
uncompress = self.decompress.decompress(buf)
self._add_read_data( uncompress )
@@ -216,11 +216,11 @@ class GzipFile:
self.fileobj.seek( -len(self.decompress.unused_data)+8, 1)
# Check the CRC and file size, and set the flag so we read
- # a new member on the next call
+ # a new member on the next call
self._read_eof()
- self._new_member = 1
-
- def _add_read_data(self, data):
+ self._new_member = 1
+
+ def _add_read_data(self, data):
self.crc = zlib.crc32(data, self.crc)
self.extrabuf = self.extrabuf + data
self.extrasize = self.extrasize + len(data)
@@ -228,7 +228,7 @@ class GzipFile:
def _read_eof(self):
# We've read to the end of the file, so we have to rewind in order
- # to reread the 8 bytes containing the CRC and the file size.
+ # to reread the 8 bytes containing the CRC and the file size.
# We check the that the computed CRC and size of the
# uncompressed data matches the stored values.
self.fileobj.seek(-8, 1)
@@ -238,7 +238,7 @@ class GzipFile:
raise ValueError, "CRC check failed"
elif isize != self.size:
raise ValueError, "Incorrect length of data produced"
-
+
def close(self):
if self.mode == WRITE:
self.fileobj.write(self.compress.flush())
@@ -259,7 +259,7 @@ class GzipFile:
except AttributeError:
return
self.close()
-
+
def flush(self):
self.fileobj.flush()
@@ -285,7 +285,7 @@ class GzipFile:
i = string.find(c, '\n')
if size is not None:
# We set i=size to break out of the loop under two
- # conditions: 1) there's no newline, and the chunk is
+ # conditions: 1) there's no newline, and the chunk is
# larger than size, or 2) there is a newline, but the
# resulting line would be longer than 'size'.
if i==-1 and len(c) > size: i=size-1
@@ -300,7 +300,7 @@ class GzipFile:
bufs.append(c)
size = size - len(c)
readsize = min(size, readsize * 2)
-
+
def readlines(self, sizehint=0):
# Negative numbers result in reading all the lines
if sizehint <= 0: sizehint = sys.maxint