summaryrefslogtreecommitdiff
path: root/Lib/chunk.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-06-25 14:58:44 +0000
committerFred Drake <fdrake@acm.org>1999-06-25 14:58:44 +0000
commit0d124a4b7cb49508fb3c8b81759a32f26ba45182 (patch)
tree119eae192b3df7c0ebf32bf2edcbb65ce5f91f4d /Lib/chunk.py
parentae3e0496f8a52f919736f732246731546170a09a (diff)
downloadcpython-0d124a4b7cb49508fb3c8b81759a32f26ba45182.tar.gz
Patch from Sjoerd Mullender:
Make argument names equal to what is used in the documentation of the file object, since chunks are supposedly file-like.
Diffstat (limited to 'Lib/chunk.py')
-rw-r--r--Lib/chunk.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Lib/chunk.py b/Lib/chunk.py
index 4105f319a8..231a59caff 100644
--- a/Lib/chunk.py
+++ b/Lib/chunk.py
@@ -17,7 +17,7 @@ The ID is a 4-byte string which identifies the type of chunk.
The size field (a 32-bit value, encoded using big-endian byte order)
gives the size of the whole chunk, including the 8-byte header.
-Usually a IFF-type file consists of one or more chunks. The proposed
+Usually an IFF-type file consists of one or more chunks. The proposed
usage of the Chunk class defined here is to instantiate an instance at
the start of each chunk and read from the instance until it reaches
the end, after which a new instance can be instantiated. At the end
@@ -84,7 +84,7 @@ class Chunk:
raise ValueError, "I/O operation on closed file"
return 0
- def seek(self, pos, mode = 0):
+ def seek(self, pos, whence = 0):
"""Seek to specified position into the chunk.
Default position is 0 (start of chunk).
If the file is not seekable, this will result in an error.
@@ -94,9 +94,9 @@ class Chunk:
raise ValueError, "I/O operation on closed file"
if not self.seekable:
raise IOError, "cannot seek"
- if mode == 1:
+ if whence == 1:
pos = pos + self.size_read
- elif mode == 2:
+ elif whence == 2:
pos = pos + self.chunk_size
if pos < 0 or pos > self.chunksize:
raise RuntimeError
@@ -108,9 +108,9 @@ class Chunk:
raise ValueError, "I/O operation on closed file"
return self.size_read
- def read(self, n = -1):
- """Read at most n bytes from the chunk.
- If n is omitted or negative, read until the end
+ def read(self, size = -1):
+ """Read at most size bytes from the chunk.
+ If size is omitted or negative, read until the end
of the chunk.
"""
@@ -118,11 +118,11 @@ class Chunk:
raise ValueError, "I/O operation on closed file"
if self.size_read >= self.chunksize:
return ''
- if n < 0:
- n = self.chunksize - self.size_read
- if n > self.chunksize - self.size_read:
- n = self.chunksize - self.size_read
- data = self.file.read(n)
+ if size < 0:
+ size = self.chunksize - self.size_read
+ if size > self.chunksize - self.size_read:
+ size = self.chunksize - self.size_read
+ data = self.file.read(size)
self.size_read = self.size_read + len(data)
if self.size_read == self.chunksize and \
self.align and \