def make_capture_protocol():
 d = Deferred()
 captured_data = []
 class Recorder(Protocol, ):
  def dataReceived(self, data):
   captured_data.append(data)
  def connectionLost(self, reason):
   if reason.check(ConnectionDone):
    d.callback(''.join(captured_data))
   else:
    d.errback(reason)
 return (d, Recorder())

def make_capture_protocol ( ) : d = Deferred ( ) captured_data = [ ] class Recorder ( Protocol , ) : def dataReceived ( self , data ) : captured_data . append ( data ) def connectionLost ( self , reason ) : if reason . check ( ConnectionDone ) : d . callback ( '' . join ( captured_data ) ) else : d . errback ( reason ) return ( d , Recorder ( ) )
return a deferred .