[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-138]
doc fixups little doc fixups that i did obsessively on the train one morning.
This commit is contained in:
parent
1eda9b051b
commit
b89025d409
|
@ -35,7 +35,7 @@ _FLAG_UNIVERSAL_NEWLINE = 0x80
|
||||||
class BufferedFile (object):
|
class BufferedFile (object):
|
||||||
"""
|
"""
|
||||||
Reusable base class to implement python-style file buffering around a
|
Reusable base class to implement python-style file buffering around a
|
||||||
simpler stream
|
simpler stream.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_DEFAULT_BUFSIZE = 8192
|
_DEFAULT_BUFSIZE = 8192
|
||||||
|
@ -112,7 +112,7 @@ class BufferedFile (object):
|
||||||
@param size: maximum number of bytes to read.
|
@param size: maximum number of bytes to read.
|
||||||
@type size: int
|
@type size: int
|
||||||
@return: data read from the file, or an empty string if EOF was
|
@return: data read from the file, or an empty string if EOF was
|
||||||
encountered immediately.
|
encountered immediately.
|
||||||
@rtype: str
|
@rtype: str
|
||||||
"""
|
"""
|
||||||
if self._closed:
|
if self._closed:
|
||||||
|
@ -124,7 +124,7 @@ class BufferedFile (object):
|
||||||
result = self._rbuffer
|
result = self._rbuffer
|
||||||
self._rbuffer = ''
|
self._rbuffer = ''
|
||||||
self._pos += len(result)
|
self._pos += len(result)
|
||||||
while 1:
|
while True:
|
||||||
try:
|
try:
|
||||||
new_data = self._read(self._DEFAULT_BUFSIZE)
|
new_data = self._read(self._DEFAULT_BUFSIZE)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
|
@ -169,14 +169,16 @@ class BufferedFile (object):
|
||||||
@param size: maximum length of returned string.
|
@param size: maximum length of returned string.
|
||||||
@type size: int
|
@type size: int
|
||||||
@return: next line of the file, or an empty string if the end of the
|
@return: next line of the file, or an empty string if the end of the
|
||||||
file has been reached.
|
file has been reached.
|
||||||
@rtype: str
|
@rtype: str
|
||||||
"""
|
"""
|
||||||
# it's almost silly how complex this function is.
|
# it's almost silly how complex this function is.
|
||||||
if self._closed:
|
if self._closed:
|
||||||
raise IOError('File is closed')
|
raise IOError('File is closed')
|
||||||
|
if not (self._flags & _FLAG_READ):
|
||||||
|
raise IOError('File not open for reading')
|
||||||
line = self._rbuffer
|
line = self._rbuffer
|
||||||
while 1:
|
while True:
|
||||||
if self._at_trailing_cr and (self._flags & _FLAG_UNIVERSAL_NEWLINE) and (len(line) > 0):
|
if self._at_trailing_cr and (self._flags & _FLAG_UNIVERSAL_NEWLINE) and (len(line) > 0):
|
||||||
# edge case: the newline may be '\r\n' and we may have read
|
# edge case: the newline may be '\r\n' and we may have read
|
||||||
# only the first '\r' last time.
|
# only the first '\r' last time.
|
||||||
|
@ -261,14 +263,14 @@ class BufferedFile (object):
|
||||||
objects support seeking.
|
objects support seeking.
|
||||||
|
|
||||||
@note: If a file is opened in append mode (C{'a'} or C{'a+'}), any seek
|
@note: If a file is opened in append mode (C{'a'} or C{'a+'}), any seek
|
||||||
operations will be undone at the next write (as the file position will
|
operations will be undone at the next write (as the file position
|
||||||
move back to the end of the file).
|
will move back to the end of the file).
|
||||||
|
|
||||||
@param offset: position to move to within the file, relative to
|
@param offset: position to move to within the file, relative to
|
||||||
C{whence}.
|
C{whence}.
|
||||||
@type offset: int
|
@type offset: int
|
||||||
@param whence: type of movement: 0 = absolute; 1 = relative to the
|
@param whence: type of movement: 0 = absolute; 1 = relative to the
|
||||||
current position; 2 = relative to the end of the file.
|
current position; 2 = relative to the end of the file.
|
||||||
@type whence: int
|
@type whence: int
|
||||||
|
|
||||||
@raise IOError: if the file doesn't support random access.
|
@raise IOError: if the file doesn't support random access.
|
||||||
|
|
Loading…
Reference in New Issue