|
1 #!/usr/bin/env python |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # See COPYING file for copyrights details. |
|
5 |
|
6 from __future__ import absolute_import |
|
7 |
|
8 from itertools import repeat, islice, chain |
|
9 import wx |
|
10 |
|
11 from connectors.SchemeEditor import SchemeEditor |
|
12 |
|
13 |
|
14 model = [('host',_("Host:")), |
|
15 ('port',_("Port:"))] |
|
16 |
|
17 secure_model = model + [('ID',_("ID:"))] |
|
18 |
|
19 models = [("LOCAL", []), ("PYRO",model), ("PYROS",secure_model)] |
|
20 |
|
21 Schemes = list(zip(*models)[0]) |
|
22 |
|
23 ModelsDict = dict(models) |
|
24 |
|
25 class PYRO_dialog(SchemeEditor): |
|
26 def __init__(self, scheme, *args, **kwargs): |
|
27 self.model = ModelsDict[scheme] |
|
28 SchemeEditor.__init__(self, scheme, *args, **kwargs) |
|
29 |
|
30 def SetLoc(self, loc): |
|
31 hostport, ID = list(islice(chain(loc.split("#"), repeat("")),2)) |
|
32 host, port = list(islice(chain(hostport.split(":"), repeat("")),2)) |
|
33 self.SetFields(locals()) |
|
34 |
|
35 def GetLoc(self): |
|
36 if self.model: |
|
37 fields = self.GetFields() |
|
38 template = "{host}" |
|
39 if fields['port']: |
|
40 template += ":{port}" |
|
41 |
|
42 return template.format(**fields) |
|
43 return '' |
|
44 |