~cbehrens/nova/lp844160-build-works-with-zones

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/words/protocols/jabber/jstrports.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- test-case-name: twisted.words.test -*-
 
2
# Copyright (c) 2001-2005 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
 
 
6
""" A temporary placeholder for client-capable strports, until we
 
7
sufficient use cases get identified """
 
8
 
 
9
from twisted.application import strports
 
10
 
 
11
def _parseTCPSSL(factory, domain, port):
 
12
    """ For the moment, parse TCP or SSL connections the same """
 
13
    return (domain, int(port), factory), {}
 
14
 
 
15
def _parseUNIX(factory, address):
 
16
    return (address, factory), {}
 
17
 
 
18
 
 
19
_funcs = { "tcp"  : _parseTCPSSL,
 
20
           "unix" : _parseUNIX,
 
21
           "ssl"  : _parseTCPSSL }
 
22
 
 
23
 
 
24
def parse(description, factory):
 
25
    args, kw = strports._parse(description)
 
26
    return (args[0].upper(),) + _funcs[args[0]](factory, *args[1:], **kw)
 
27
 
 
28
def client(description, factory):
 
29
    from twisted.application import internet
 
30
    name, args, kw = parse(description, factory)
 
31
    return getattr(internet, name + 'Client')(*args, **kw)