summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Pipek <jan.pipek@gmail.com>2019-09-10 15:53:10 +0200
committerJan Pipek <jan.pipek@gmail.com>2019-09-10 15:53:10 +0200
commit043d97d7ecd01da7c5ac43a0e87565ba0f3bd35b (patch)
tree16287ad784f2012872fa1d749c6dd1a6131f1d2a
parent56f33ff38a4ba4dedc23e095d509f2f20f373ba2 (diff)
downloadpyasn1-git-043d97d7ecd01da7c5ac43a0e87565ba0f3bd35b.tar.gz
Docstrings in requested format.
-rw-r--r--pyasn1/codec/ber/decoder.py46
1 files changed, 38 insertions, 8 deletions
diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py
index 9fa5374..0bd804c 100644
--- a/pyasn1/codec/ber/decoder.py
+++ b/pyasn1/codec/ber/decoder.py
@@ -34,10 +34,20 @@ _PY2 = sys.version_info < (3,)
def asSeekableStream(substrate):
- """Convert object to seekable bytes stream.
+ """Convert object to seekable byte-stream.
- :type substrate: Union[bytes, IOBase, univ.OctetString]
- :rtype: IOBase
+ Parameters
+ ----------
+ substrate: :py:class:`bytes` or :py:class:`io.IOBase` or :py:class:`univ.OctetString`
+
+ Returns
+ -------
+ : :py:class:`io.IOBase`
+
+ Raises
+ ------
+ ~pyasn1.error.PyAsn1Error
+ If the supplied substrate cannot be converted to a seekable stream.
"""
if isinstance(substrate, bytes):
return BytesIO(substrate)
@@ -56,10 +66,19 @@ def asSeekableStream(substrate):
def endOfStream(substrate):
- """Check whether we have reached an end of stream.
+ """Check whether we have reached the end of a stream.
+
+ Although it is more effective to read and catch exceptions, this
+ function
- :type substrate: IOBase
- :rtype: bool
+ Parameters
+ ----------
+ substrate: :py:class:`IOBase`
+ Stream to check
+
+ Returns
+ -------
+ : :py:class:`bool`
"""
if isinstance(substrate, BytesIO):
cp = substrate.tell()
@@ -72,9 +91,20 @@ def endOfStream(substrate):
def peek(substrate, size=-1):
- """Peak the stream
+ """Peek the stream.
+
+ Parameters
+ ----------
+ substrate: :py:class:`IOBase`
+ Stream to read from.
+
+ size: :py:class:`int`
+ How many bytes to peek (-1 = all available)
- :param size:
+ Returns
+ -------
+ : :py:class:`bytes` or :py:class:`str`
+ The return type depends on Python major version
"""
if hasattr(substrate, "peek"):
return substrate.peek(size)