OLD | NEW |
| (Empty) |
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) | |
OLD | NEW |