Skip to content

adjunct.netstrings

Simple netstring reader implemented as a generator.

MalformedNetstringError

Bases: Exception

Raised when the netstring reader hits a parser error in the stream.

netstring_reader(fd)

Read a sequence of netstrings from the given file object.

Parameters:

Name Type Description Default
fd BufferedIOBase

a file-like object to read from

required

Yields:

Type Description
Iterable[bytes]

netstrings

parse(ns)

Parse a bytestring of netstrings.

Parameters:

Name Type Description Default
ns bytes

the netstrings to parse; there may be multiple in the input buffer

required

Returns:

Type Description
Sequence[bytes]

All the netstrings found in the input buffer