tubes.tube
module documentationtubes
See tube
.
Function | skip | A token value yielded by a tube meaning that its _Siphon should not
deliver this value on, so that tubes may engage in flow control. |
Function | tube | No summary |
Function | receiver | Decorator for a stateless function which receives inputs. |
Function | series | No summary |
Class | Diverter | A Diverter is a drain which maintains a
buffer of items not yet received by its IDivertable
down-stream drain. |
Class | _Tubule | A tube created for the @tube decorator. |
Class | _DrainingTube | A _DrainingTube
is an ITube that
unbuffers a list of items. It is an implementation detail of the way that
Diverter works. |
Class | _NullFount | An almost no-op implementation of fount which does nothing but
update its drain to point at itself. |
A token value yielded by a tube meaning that its _Siphon
should not
deliver this value on, so that tubes may engage in flow control.
tube
is a class
decorator which declares a given class to be an implementer of ITube
and fills out any
methods or attributes which are not present on the decorated type with
null-implementation methods (those which return None) and None
attributes.
Parameters | cls | A class with some or all of the attributes or methods described by ITube . (type: type ) |
Returns | cls (type: type
which implements ITube ) |
Decorator for a stateless function which receives inputs.
For example, to add 1 to each in a stream of numbers:
@receiver(inputType=int, outputType=int) def addOne(item): yield item + 1
Parameters | inputType | The inputType attribute of the resulting ITube . |
outputType | The outputType attribute of the resulting ITube . | |
name | a name describing the tubule for it to show as in a repr . (type: native str ) | |
Returns | a stateless tube with the decorated method as its received
method. (type: ITube ) |
Connect up a series of objects capable of transforming inputs to
outputs; convert a sequence of ITube
objects into a
sequence of connected IFount
and IDrain
objects. This is
necessary to be able to flowTo
an object implementing ITube
.
This function can best be understood by understanding that:
x = a a.flowTo(b).flowTo(c)
is roughly analagous to:
x = series(a, b, c)
with the additional feature that series
will convert
a
, b
, and c
to the requisite IDrain
objects first.
Parameters | start | The initial element in the chain; the object that will consume inputs
passed to the result of this call to series . (type: an ITube , or anything
adaptable to IDrain .) |
tubes | Each element of plumbing . (type: a tuple
of ITube s or objects
adaptable to IDrain .) | |
Returns | An IDrain that can
consume inputs of start 's inputType , and whose
flowingFrom will return an IFount that will produce
outputs of plumbing[-1] (or start , if plumbing is
empty). (type: IDrain ) | |
Raises | TypeError | if start , or any element of plumbing is not
adaptable to IDrain . |