Package buildbot :: Package util :: Module netstrings :: Class NetstringParser
[frames] | no frames]

Class NetstringParser

source code

twisted.internet.protocol.BaseProtocol --+        
                                         |        
        twisted.internet.protocol.Protocol --+    
                                             |    
     twisted.protocols.basic.NetstringReceiver --+
                                                 |
                                                NetstringParser
Known Subclasses:

Adapts the Twisted netstring support (which assumes it is on a socket) to work on simple strings, too. Call the feed method with arbitrary blocks of data, and override the stringReceived method to get called for each embedded netstring. The default implementation collects the netstrings in the list self.strings.

Instance Methods
 
__init__(self) source code
 
feed(self, data)
Add arbitrariliy-sized data to the incoming-data buffer.
source code
 
stringReceived(self, string)
Override this for notification when each complete string is received.
source code

Inherited from twisted.protocols.basic.NetstringReceiver: dataReceived, makeConnection, sendString

Inherited from twisted.internet.protocol.Protocol: __provides__, connectionLost, logPrefix

Inherited from twisted.internet.protocol.BaseProtocol: __providedBy__, connectionMade

Class Variables

Inherited from twisted.internet.protocol.Protocol: __implemented__

Inherited from twisted.internet.protocol.BaseProtocol: connected, transport

Instance Variables

Inherited from twisted.protocols.basic.NetstringReceiver: MAX_LENGTH, brokenPeer

Method Details

feed(self, data)

source code 

Add arbitrariliy-sized data to the incoming-data buffer. Any complete netstrings will trigger a call to the stringReceived method.

Note that this method (and the Twisted class it is based on) cannot detect a trailing partial netstring at EOF - the data will be silently ignored.

@raise twisted.protocols.basic.NetstringParseError: if invalid

stringReceived(self, string)

source code 

Override this for notification when each complete string is received.

Parameters:
  • string - The complete string which was received with all framing (length prefix, etc) removed.
Raises:
  • NotImplementedError - because the method has to be implemented by the child class.
Overrides: twisted.protocols.basic.NetstringReceiver.stringReceived
(inherited documentation)