Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: third_party/twisted_8_1/twisted/protocols/stateful.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/twisted_8_1/twisted/protocols/stateful.py
diff --git a/third_party/twisted_8_1/twisted/protocols/stateful.py b/third_party/twisted_8_1/twisted/protocols/stateful.py
deleted file mode 100644
index 75313f61ffc4fa320a8dceb480f46fe057fdad24..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/protocols/stateful.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- test-case-name: twisted.test.test_stateful -*-
-
-# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-
-from twisted.internet import protocol
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-
-class StatefulProtocol(protocol.Protocol):
- """A Protocol that stores state for you.
-
- state is a pair (function, num_bytes). When num_bytes bytes of data arrives
- from the network, function is called. It is expected to return the next
- state or None to keep same state. Initial state is returned by
- getInitialState (override it).
- """
- _sful_data = None, None, 0
-
- def makeConnection(self, transport):
- protocol.Protocol.makeConnection(self, transport)
- self._sful_data = self.getInitialState(), StringIO(), 0
-
- def getInitialState(self):
- raise NotImplementedError
-
- def dataReceived(self, data):
- state, buffer, offset = self._sful_data
- buffer.seek(0, 2)
- buffer.write(data)
- blen = buffer.tell() # how many bytes total is in the buffer
- buffer.seek(offset)
- while blen - offset >= state[1]:
- d = buffer.read(state[1])
- offset += state[1]
- next = state[0](d)
- if self.transport.disconnecting: # XXX: argh stupid hack borrowed right from LineReceiver
- return # dataReceived won't be called again, so who cares about consistent state
- if next:
- state = next
- if offset != 0:
- b = buffer.read()
- buffer.reset()
- buffer.truncate()
- buffer.write(b)
- offset = 0
- self._sful_data = state, buffer, offset
-
« no previous file with comments | « third_party/twisted_8_1/twisted/protocols/socks.py ('k') | third_party/twisted_8_1/twisted/protocols/sux.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698