~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/words/protocols/jabber/jstrports.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-17 14:52:35 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20070117145235-btmig6qfmqfen0om
Tags: 2.5.0-0ubuntu1
New upstream version, compatible with python2.5.

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)