diff --git a/pyasn1/codec/ber/decoder.py b/pyasn1/codec/ber/decoder.py index 90e70ae8ecbff0d9db9ee0038afd2a51fd4c0db2_cHlhc24xL2NvZGVjL2Jlci9kZWNvZGVyLnB5..6039001c7b9de147e4dc142f03c5b8f50fdfc138_cHlhc24xL2NvZGVjL2Jlci9kZWNvZGVyLnB5 100644 --- a/pyasn1/codec/ber/decoder.py +++ b/pyasn1/codec/ber/decoder.py @@ -34,5 +34,9 @@ def asSeekableStream(substrate): - """Convert object to seekable bytes stream. + """Convert object to seekable byte-stream. + + Parameters + ---------- + substrate: :py:class:`bytes` or :py:class:`io.IOBase` or :py:class:`univ.OctetString` @@ -38,6 +42,12 @@ - :type substrate: Union[bytes, IOBase, univ.OctetString] - :rtype: IOBase + 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,5 +66,8 @@ 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 @@ -60,6 +73,12 @@ - :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,5 +91,10 @@ def peek(substrate, size=-1): - """Peak the stream + """Peek the stream. + + Parameters + ---------- + substrate: :py:class:`IOBase` + Stream to read from. @@ -76,5 +100,11 @@ - :param size: + size: :py:class:`int` + How many bytes to peek (-1 = all available) + + Returns + ------- + : :py:class:`bytes` or :py:class:`str` + The return type depends on Python major version """ if hasattr(substrate, "peek"): return substrate.peek(size)