--- a/connectors/__init__.py Thu Apr 19 09:50:00 2018 +0200
+++ b/connectors/__init__.py Fri Apr 20 11:21:20 2018 +0200
@@ -36,6 +36,12 @@
def _GetLocalConnectorClassFactory(name):
return lambda: getattr(__import__(name, globals(), locals()), name + "_connector_factory")
+def _GetLocalConnectorClassDialog(name):
+ return lambda: getattr(__import__(name, globals(), locals()), name + "_connector_dialog")
+
+def _GetLocalConnectorURITypes(name):
+ return lambda: getattr(__import__(name, globals(), locals()), "URITypes", None)
+
connectors = {name:
_GetLocalConnectorClassFactory(name)
@@ -43,6 +49,12 @@
if (path.isdir(path.join(_base_path, name)) and
not name.startswith("__"))}
+connectors_dialog = {name:
+ {"function":_GetLocalConnectorClassDialog(name), "URITypes": _GetLocalConnectorURITypes(name)}
+ for name in listdir(_base_path)
+ if (path.isdir(path.join(_base_path, name)) and
+ not name.startswith("__"))}
+
def ConnectorFactory(uri, confnodesroot):
"""
@@ -68,3 +80,22 @@
# import module according to uri type
connectorclass = connectors[servicetype]()
return connectorclass(uri, confnodesroot)
+
+
+def ConnectorDialog(type, confnodesroot):
+ if type not in connectors_dialog:
+ return None
+
+ connectorclass = connectors_dialog[type]["function"]()
+ return connectorclass(confnodesroot)
+
+def GetConnectorFromURI(uri):
+ typeOfConnector = None
+ for t in connectors_dialog:
+ connectorTypes = connectors_dialog[t]["URITypes"]()
+ if connectorTypes and uri in connectorTypes:
+ typeOfConnector = t
+ break
+
+ return typeOfConnector
+