Exemplo n.º 1
0
 def newParticipantFlow(self, fount, drain):
     commandFount = fount.flowTo(
         series(OnStop(lambda: self.participants.remove(participant)),
                bytesToLines(), linesToCommands))
     commandDrain = series(commandsToLines, linesToBytes(), drain)
     participant = Participant(self, commandFount, commandDrain)
     self.participants.append(participant)
Exemplo n.º 2
0
 def newParticipantFlow(self, fount, drain):
     commandFount = fount.flowTo(
         series(OnStop(lambda: self.participants.remove(participant)),
                bytesToLines(), linesToCommands)
     )
     commandDrain = series(commandsToLines, linesToBytes(), drain)
     participant = Participant(self, commandFount, commandDrain)
     self.participants.append(participant)
Exemplo n.º 3
0
Arquivo: rpn.py Projeto: ralphm/tubes
def promptingCalculatorSeries():
    from twisted.tubes.fan import Thru
    from twisted.tubes.tube import series
    from twisted.tubes.framing import bytesToLines, linesToBytes

    full = series(bytesToLines(),
                  Thru([series(linesToNumbersOrOperators,
                               CalculatingTube(Calculator()),
                               numbersToLines,
                               linesToBytes()),
                        series(Prompter())]))
    return full
Exemplo n.º 4
0
    def participate(self, participant):
        @receiver(IMapping, IMapping)
        def addSender(item):
            yield dict(item, sender=participant, channel=self._name)

        return (self._out.newFount(),
                series(addSender, self._in.newDrain()))
Exemplo n.º 5
0
Arquivo: rpn.py Projeto: ralphm/tubes
def calculatorSeries():
    from twisted.tubes.tube import series
    from twisted.tubes.framing import bytesToLines, linesToBytes

    return series(
        bytesToLines(),
        linesToNumbersOrOperators,
        CalculatingTube(Calculator()),
        numbersToLines,
        linesToBytes()
    )
Exemplo n.º 6
0
    def __init__(self, hub, requestsFount, responsesDrain):
        self._hub = hub
        self._participation = {}
        self._in = In()
        self._router = Router()
        self._participating = {}

        # self._in is both commands from our own client and also messages from
        # other clients.
        requestsFount.flowTo(self._in.newDrain())
        self._in.fount.flowTo(series(self, self._router.drain))

        self.client = self._router.newRoute()
        self.client.flowTo(responsesDrain)
Exemplo n.º 7
0
    def __init__(self, hub, requestsFount, responsesDrain):
        self._hub = hub
        self._participation = {}
        self._in = In()
        self._router = Router()
        self._participating = {}

        # self._in is both commands from our own client and also messages from
        # other clients.
        requestsFount.flowTo(self._in.newDrain())
        self._in.fount.flowTo(series(self, self._router.drain))

        self.client = self._router.newRoute()
        self.client.flowTo(responsesDrain)
Exemplo n.º 8
0
def mathFlow(fount, drain):
    fount.flowTo(
        series(packedPrefixToStrings(16), StringsToBoxes(),
               BoxConsumer(Math()), BoxesToData(), drain))
Exemplo n.º 9
0
def mathFlow(fount, drain):
    fount.flowTo(series(packedPrefixToStrings(16), StringsToBoxes(),
                        BoxConsumer(Math()), BoxesToData(), drain))
Exemplo n.º 10
0
    def participate(self, participant):
        @receiver(IMapping, IMapping)
        def addSender(item):
            yield dict(item, sender=participant, channel=self._name)

        return (self._out.newFount(), series(addSender, self._in.newDrain()))
Exemplo n.º 11
0
def reverseFlow(fount, drain):
    from twisted.tubes.framing import bytesToLines, linesToBytes
    lineReverser = series(bytesToLines(), Reverser(), linesToBytes())
    fount.flowTo(lineReverser).flowTo(drain)