Skip to content

Commit aeb000c

Browse files
author
fdrake
committed
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. git-svn-id: http://svn.python.org/projects/python/trunk@13575 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent beffda0 commit aeb000c

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

Lib/chunk.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
The size field (a 32-bit value, encoded using big-endian byte order)
1818
gives the size of the whole chunk, including the 8-byte header.
1919
20-
Usually a IFF-type file consists of one or more chunks. The proposed
20+
Usually an IFF-type file consists of one or more chunks. The proposed
2121
usage of the Chunk class defined here is to instantiate an instance at
2222
the start of each chunk and read from the instance until it reaches
2323
the end, after which a new instance can be instantiated. At the end
@@ -84,7 +84,7 @@ def isatty(self):
8484
raise ValueError, "I/O operation on closed file"
8585
return 0
8686

87-
def seek(self, pos, mode = 0):
87+
def seek(self, pos, whence = 0):
8888
"""Seek to specified position into the chunk.
8989
Default position is 0 (start of chunk).
9090
If the file is not seekable, this will result in an error.
@@ -94,9 +94,9 @@ def seek(self, pos, mode = 0):
9494
raise ValueError, "I/O operation on closed file"
9595
if not self.seekable:
9696
raise IOError, "cannot seek"
97-
if mode == 1:
97+
if whence == 1:
9898
pos = pos + self.size_read
99-
elif mode == 2:
99+
elif whence == 2:
100100
pos = pos + self.chunk_size
101101
if pos < 0 or pos > self.chunksize:
102102
raise RuntimeError
@@ -108,21 +108,21 @@ def tell(self):
108108
raise ValueError, "I/O operation on closed file"
109109
return self.size_read
110110

111-
def read(self, n = -1):
112-
"""Read at most n bytes from the chunk.
113-
If n is omitted or negative, read until the end
111+
def read(self, size = -1):
112+
"""Read at most size bytes from the chunk.
113+
If size is omitted or negative, read until the end
114114
of the chunk.
115115
"""
116116

117117
if self.closed:
118118
raise ValueError, "I/O operation on closed file"
119119
if self.size_read >= self.chunksize:
120120
return ''
121-
if n < 0:
122-
n = self.chunksize - self.size_read
123-
if n > self.chunksize - self.size_read:
124-
n = self.chunksize - self.size_read
125-
data = self.file.read(n)
121+
if size < 0:
122+
size = self.chunksize - self.size_read
123+
if size > self.chunksize - self.size_read:
124+
size = self.chunksize - self.size_read
125+
data = self.file.read(size)
126126
self.size_read = self.size_read + len(data)
127127
if self.size_read == self.chunksize and \
128128
self.align and \

0 commit comments

Comments
 (0)