1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from twisted.protocols import basic
17 from zope.interface import implements
18 from twisted.internet.interfaces import IAddress, ITransport
19
21 "an address for NullTransport"
22 implements(IAddress)
23
25 "a do-nothing transport to make NetstringReceiver happy"
26 implements(ITransport)
27 - def write(self, data): raise NotImplementedError
34
36 """
37 Adapts the Twisted netstring support (which assumes it is on a socket) to
38 work on simple strings, too. Call the C{feed} method with arbitrary blocks
39 of data, and override the C{stringReceived} method to get called for each
40 embedded netstring. The default implementation collects the netstrings in
41 the list C{self.strings}.
42 """
43
45
46
47 self.makeConnection(NullTransport())
48 self.strings = []
49
50 - def feed(self, data):
51 """
52 """
53 self.dataReceived(data)
54
55 if self.brokenPeer:
56 raise basic.NetstringParseError
57
59 self.strings.append(string)
60