r47164 - remove haproxy from 'endpoints' module entirely

glyph-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Tue, 5 Apr 2016 16:30:55 -0600 (MDT)
Newsgroups gmane.comp.python.twisted.commits
Message-ID <[email protected]>
Author: glyph
Date: Tue Apr  5 16:30:50 2016
New Revision: 47164

Added:
   branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/_parser.py
   branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/test/test_parser.py
Modified:
   branches/haproxy-endpoint-8203-2/twisted/internet/endpoints.py
   branches/haproxy-endpoint-8203-2/twisted/internet/test/test_endpoints.py
   branches/haproxy-endpoint-8203-2/twisted/plugins/twisted_core.py
   branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/__init__.py
   branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/_wrapper.py
   branches/haproxy-endpoint-8203-2/twisted/python/dist3.py

Log:
remove haproxy from 'endpoints' module entirely

Modified: branches/haproxy-endpoint-8203-2/twisted/internet/endpoints.py
==============================================================================
--- branches/haproxy-endpoint-8203-2/twisted/internet/endpoints.py	(original)
+++ branches/haproxy-endpoint-8203-2/twisted/internet/endpoints.py	Tue Apr  5 16:30:50 2016
@@ -34,7 +34,6 @@
 from twisted.internet.stdio import StandardIO, PipeAddress
 from twisted.internet.task import LoopingCall
 from twisted.plugin import IPlugin, getPlugins
-from twisted.protocols import haproxy
 from twisted.python import log
 from twisted.python.compat import nativeString, unicode, _matchingString
 from twisted.python.components import proxyForInterface
@@ -42,7 +41,6 @@
 from twisted.python.failure import Failure
 from twisted.python.filepath import FilePath
 from twisted.python.compat import iterbytes
-from twisted.python.compat import iteritems
 from twisted.python.systemd import ListenFDs
 
 
@@ -1283,41 +1281,6 @@
 
 
 
-@implementer(IPlugin, IStreamServerEndpointStringParser)
-class _HAProxyServerParser(object):
-    """
-    Stream server endpoint string parser for the HAProxyServerEndpoint type.
-
-    @ivar prefix: See L{IStreamServerEndpointStringParser.prefix}.
-    """
-    prefix = "haproxy"
-
-    def _parseServer(self, reactor, *args, **kwargs):
-        """
-        Internal parser function.
-
-        @param reactor: An L{IReactorTCP} provider.
-
-        @param wrapped: The name of the endpoint to wrap. Ex: tcp6.
-        @type wrapped: str
-        """
-        # Rebuild the description to re-dispatch the request.
-        description = ':'.join(str(arg) for arg in args)
-        description += ':'.join(
-            '%s=%s' % (str(key), quoteStringArgument(str(value)))
-            for key, value in iteritems(kwargs)
-        )
-        return _WrapperServerEndpoint(
-            serverFromString(reactor, description),
-            haproxy.HAProxyWrappingFactory,
-        )
-
-
-    def parseStreamServer(self, reactor, *args, **kwargs):
-        return self._parseServer(reactor, *args, **kwargs)
-
-
-
 _serverParsers = {"tcp": _parseTCP,
                   "unix": _parseUNIX,
                   "ssl": _parseSSL,

Modified: branches/haproxy-endpoint-8203-2/twisted/internet/test/test_endpoints.py
==============================================================================
--- branches/haproxy-endpoint-8203-2/twisted/internet/test/test_endpoints.py	(original)
+++ branches/haproxy-endpoint-8203-2/twisted/internet/test/test_endpoints.py	Tue Apr  5 16:30:50 2016
@@ -3729,50 +3729,3 @@
         notImplemented = self.assertRaises(NotImplementedError, replaced,
                                            None, None)
         self.assertIn("OpenSSL not available", str(notImplemented))
-
-
-class HAProxyServerParserTests(unittest.TestCase):
-    """
-    Tests that the parser generates the correct endpoints.
-    """
-
-    def test_tcp4(self):
-        """
-        Test if the parser generates a wrapped TCP4 endpoint.
-        """
-        parser = endpoints._HAProxyServerParser()
-        server = parser.parseStreamServer(reactor, 'haproxy', 'tcp', '8080')
-        self.assertIsInstance(server, endpoints._WrapperServerEndpoint)
-        self.assertIsInstance(
-            server._wrappedEndpoint._wrappedEndpoint,
-            endpoints.TCP4ServerEndpoint,
-        )
-
-    def test_tcp6(self):
-        """
-        Test if the parser generates a wrapped TCP6 endpoint.
-        """
-        parser = endpoints._HAProxyServerParser()
-        server = parser.parseStreamServer(reactor, 'haproxy', 'tcp6', '8080')
-        self.assertIsInstance(server, endpoints._WrapperServerEndpoint)
-        self.assertIsInstance(
-            server._wrappedEndpoint._wrappedEndpoint,
-            endpoints.TCP6ServerEndpoint,
-        )
-
-    def test_unix(self):
-        """
-        Test if the parser generates a wrapped UNIX endpoint.
-        """
-        parser = endpoints._HAProxyServerParser()
-        server = parser.parseStreamServer(
-            reactor,
-            'haproxy',
-            'unix',
-            '/tmp/test',
-        )
-        self.assertIsInstance(server, endpoints._WrapperServerEndpoint)
-        self.assertIsInstance(
-            server._wrappedEndpoint._wrappedEndpoint,
-            endpoints.UNIXServerEndpoint,
-        )

Modified: branches/haproxy-endpoint-8203-2/twisted/plugins/twisted_core.py
==============================================================================
--- branches/haproxy-endpoint-8203-2/twisted/plugins/twisted_core.py	(original)
+++ branches/haproxy-endpoint-8203-2/twisted/plugins/twisted_core.py	Tue Apr  5 16:30:50 2016
@@ -5,10 +5,14 @@
 
 from twisted.internet.endpoints import (
     _SystemdParser, _TCP6ServerParser, _StandardIOParser,
-    _TLSClientEndpointParser, _HAProxyServerParser)
+    _TLSClientEndpointParser)
+
+from twisted.protocols.haproxy._parser import (
+    HAProxyServerParser as _HAProxyServerParser
+)
 
 systemdEndpointParser = _SystemdParser()
 tcp6ServerEndpointParser = _TCP6ServerParser()
 stdioEndpointParser = _StandardIOParser()
 tlsClientEndpointParser = _TLSClientEndpointParser()
-haProxyServerEndpointParser = _HAProxyServerParser()
+_haProxyServerEndpointParser = _HAProxyServerParser()

Modified: branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/__init__.py
==============================================================================
--- branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/__init__.py	(original)
+++ branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/__init__.py	Tue Apr  5 16:30:50 2016
@@ -6,10 +6,8 @@
 HAProxy PROXY protocol implementations.
 """
 
-from ._wrapper import HAProxyProtocolWrapper
-from ._wrapper import HAProxyWrappingFactory
+from ._wrapper import proxyEndpoint
 
-__all__ = (
-    'HAProxyProtocolWrapper',
-    'HAProxyWrappingFactory',
-)
+__all__ = [
+    'proxyEndpoint',
+]

Modified: branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/_wrapper.py
==============================================================================
--- branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/_wrapper.py	(original)
+++ branches/haproxy-endpoint-8203-2/twisted/protocols/haproxy/_wrapper.py	Tue Apr  5 16:30:50 2016
@@ -9,6 +9,7 @@
 
 from twisted.protocols import policies
 from twisted.internet import interfaces
+from twisted.internet.endpoints import _WrapperServerEndpoint
 
 from ._exc import InvalidProxyHeader
 from ._v1parser import V1Parser
@@ -92,3 +93,11 @@
         else:
             logPrefix = self.wrappedFactory.__class__.__name__
         return "%s (PROXY)" % (logPrefix,)
+
+
+
+def proxyEndpoint(wrappedEndpoint):
+    """
+    
+    """
+    return _WrapperServerEndpoint(wrappedEndpoint, HAProxyWrappingFactory)

Modified: branches/haproxy-endpoint-8203-2/twisted/python/dist3.py
==============================================================================
--- branches/haproxy-endpoint-8203-2/twisted/python/dist3.py	(original)
+++ branches/haproxy-endpoint-8203-2/twisted/python/dist3.py	Tue Apr  5 16:30:50 2016
@@ -166,10 +166,12 @@
     "twisted.protocols.haproxy._v1parser",
     "twisted.protocols.haproxy._v2parser",
     "twisted.protocols.haproxy._wrapper",
+    "twisted.protocols.haproxy._parser",
     "twisted.protocols.haproxy.test.__init__",
     "twisted.protocols.haproxy.test.test_v1parser",
     "twisted.protocols.haproxy.test.test_v2parser",
     "twisted.protocols.haproxy.test.test_wrapper",
+    "twisted.protocols.haproxy.test.test_parser",
     "twisted.protocols.tls",
     "twisted.python.__init__",
     "twisted.python._appdirs",