BufferedFile

This commit is contained in:
Jeff Forcier 2014-02-21 15:43:35 -08:00
parent 5681b8c25a
commit 0d08366612
1 changed files with 10 additions and 13 deletions

View File

@ -16,10 +16,6 @@
# along with Paramiko; if not, write to the Free Software Foundation, Inc., # along with Paramiko; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
"""
BufferedFile.
"""
from cStringIO import StringIO from cStringIO import StringIO
@ -69,7 +65,6 @@ class BufferedFile (object):
:raises ValueError: if the file is closed. :raises ValueError: if the file is closed.
:return: an interator.
:rtype: iterator :rtype: iterator
""" """
if self._closed: if self._closed:
@ -94,9 +89,9 @@ class BufferedFile (object):
def next(self): def next(self):
""" """
Returns the next line from the input, or raises `.StopIteration` when Returns the next line from the input, or raises
EOF is hit. Unlike python file objects, it's okay to mix calls to `~exceptions.StopIteration` when EOF is hit. Unlike Python file
`next` and `readline`. objects, it's okay to mix calls to `next` and `readline`.
:raises StopIteration: when the end of the file is reached. :raises StopIteration: when the end of the file is reached.
@ -171,13 +166,15 @@ class BufferedFile (object):
incomplete line may be returned. An empty string is returned only when incomplete line may be returned. An empty string is returned only when
EOF is encountered immediately. EOF is encountered immediately.
.. note:: Unlike stdio's ``fgets()``, the returned string contains null .. note::
Unlike stdio's ``fgets``, the returned string contains null
characters (``'\\0'``) if they occurred in the input. characters (``'\\0'``) if they occurred in the input.
: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:
file has been reached. next line of the file, or an empty string if the end of the 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.
@ -334,7 +331,7 @@ class BufferedFile (object):
""" """
Write a sequence of strings to the file. The sequence can be any Write a sequence of strings to the file. The sequence can be any
iterable object producing strings, typically a list of strings. (The iterable object producing strings, typically a list of strings. (The
name is intended to match `readlines`; ``writelines`` does not add line name is intended to match `readlines`; `writelines` does not add line
separators.) separators.)
:param sequence: an iterable sequence of strings. :param sequence: an iterable sequence of strings.