def newParticipantFlow(self, flow): commandFount = flow.fount.flowTo( series(OnStop(lambda: self.participants.remove(participant)), bytesToLines(), linesToCommands)) commandDrain = series(commandsToLines, linesToBytes(), flow.drain) participant = Participant(self, commandFount, commandDrain) self.participants.append(participant)
def calculatorSeries(): from tubes.tube import series from tubes.framing import bytesToLines, linesToBytes return series(bytesToLines(), linesToNumbersOrOperators, CalculatingTube(Calculator()), numbersToLines, linesToBytes())
def outgoing_tube_factory(connecting_fount, connecting_drain): client_filter = or_command_filter(self.client_allowed, self.client_allowed_prefixes) client_sieve = tubeFilter(client_filter.is_allowed) client_replace = replacerTubeFactory(self.client_replacements) proxy_client_sieve = series(bytesToLines(), client_replace, client_sieve, linesToBytes()) client_fanout = Out() client_err_fount = client_fanout.newFount() client_sieve_fount = client_fanout.newFount() client_sieve_fount.flowTo(proxy_client_sieve).flowTo(connecting_drain) server_fanin = In() server_fanin.fount.flowTo(display_received("server")).flowTo(listening_drain) #server_fanin.fount.flowTo(listening_drain) server_fanin_proxy_drain = server_fanin.newDrain() server_fanin_err_drain = server_fanin.newDrain() error_sieve = tubeFilter(lambda item: not client_filter.is_allowed(item)) replace_with_error_tube = lambda err_message: tubeMap(lambda item: err_message) proxy_error_sieve = series(bytesToLines(), error_sieve, replace_with_error_tube(self.filtered_msg), linesToBytes()) client_err_fount.flowTo(series(proxy_error_sieve, server_fanin_err_drain)) server_filter = or_command_filter(self.server_allowed, self.server_allowed_prefixes) server_sieve = tubeFilter(server_filter.is_allowed) proxy_server_sieve = series(bytesToLines(), server_sieve, linesToBytes()) connecting_fount.flowTo(proxy_server_sieve).flowTo(server_fanin_proxy_drain) listening_fount.flowTo(series(display_received("client"), client_fanout.drain))
def newParticipantFlow(self, flow): commandFount = flow.fount.flowTo( series(OnStop(lambda: self.participants.remove(participant)), bytesToLines(), linesToCommands) ) commandDrain = series(commandsToLines, linesToBytes(), flow.drain) participant = Participant(self, commandFount, commandDrain) self.participants.append(participant)
def calculatorSeries(): from tubes.tube import series from tubes.framing import bytesToLines, linesToBytes return series( bytesToLines(), linesToNumbersOrOperators, CalculatingTube(Calculator()), numbersToLines, linesToBytes() )
def promptingCalculatorSeries(): from tubes.fan import Thru from tubes.tube import series from tubes.framing import bytesToLines, linesToBytes full = series(bytesToLines(), Thru([series(linesToNumbersOrOperators, CalculatingTube(Calculator()), numbersToLines, linesToBytes()), series(Prompter())])) return full
def promptingCalculatorSeries(): from tubes.fan import Thru from tubes.tube import series from tubes.framing import bytesToLines, linesToBytes full = series( bytesToLines(), Thru([ series(linesToNumbersOrOperators, CalculatingTube(Calculator()), numbersToLines, linesToBytes()), series(Prompter()) ])) return full
def reverseFlow(fount, drain): from tubes.framing import bytesToLines, linesToBytes lineReverser = series(bytesToLines(), Reverser(), linesToBytes()) fount.flowTo(lineReverser).flowTo(drain)
def reverseFlow(flow): from tubes.framing import bytesToLines, linesToBytes lineReverser = series(bytesToLines(), Reverser(), linesToBytes()) flow.fount.flowTo(lineReverser).flowTo(flow.drain)