--- a/ConfigTree.py Tue May 08 12:18:57 2012 +0200
+++ b/ConfigTree.py Tue May 08 16:31:12 2012 +0200
@@ -542,7 +542,7 @@
@param CTNType: string desining the confnode class name (get name from CTNChildrenTypes)
@param CTNName: string for the name of the confnode instance
"""
- # reorgabize self.CTNChildrenTypes tuples from (name, CTNClass, Help)
+ # reorganize self.CTNChildrenTypes tuples from (name, CTNClass, Help)
# to ( name, (CTNClass, Help)), an make a dict
transpose = zip(*self.CTNChildrenTypes)
CTNChildrenTypes = dict(zip(transpose[0],zip(transpose[1],transpose[2])))
@@ -693,11 +693,6 @@
if d["method"]==method and d.get("enabled", True) and d.get("shown", True):
getattr(self, method)()
-def _GetClassFunction(name):
- def GetRootClass():
- return getattr(__import__("confnodes." + name), name).RootClass
- return GetRootClass
-
####################################################################################
####################################################################################
@@ -735,6 +730,15 @@
DEBUG_RETRIES_WARN = 3
DEBUG_RETRIES_REREGISTER = 4
+def CTNClassFactory(classpath):
+ if type(classpath)==str:
+ def fac():
+ mod=__import__(classpath.rsplit('.',1)[0])
+ return reduce(getattr, classpath.split('.')[1:], mod)
+ return fac
+ else:
+ return lambda:classpath
+
class ConfigTreeRoot(ConfigTreeNode, PLCControler):
"""
This class define Root object of the confnode tree.
@@ -748,7 +752,7 @@
"""
# For root object, available Children Types are modules of the confnode packages.
- CTNChildrenTypes = [(name, _GetClassFunction(name), help) for name, help in zip(confnodes.__all__,confnodes.helps)]
+ CTNChildrenTypes = [(n, CTNClassFactory(c), d) for n,d,h,c in confnodes.catalog]
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
--- a/confnodes/__init__.py Tue May 08 12:18:57 2012 +0200
+++ b/confnodes/__init__.py Tue May 08 16:31:12 2012 +0200
@@ -1,13 +1,10 @@
from os import listdir, path
-_base_path = path.split(__file__)[0]
+catalog = [
+ ('canfestival', _('CANopen support'), _('Map located variables over CANopen'), 'confnodes.canfestival.canfestival.RootClass'),
+ ('c_ext', _('C extention'), _('Extend project with C code accessing located variables'), 'confnodes.c_ext.c_ext.RootClass'),
+ ('python', _('Python extention'), _('Extend project with Pyhon code executed asynchronously'), 'confnodes.python.python.RootClass')]
+# ('ethercat_master', _('Ethercat master'), _('Map located variables over EtherCat, as a master'), 'ethercat.EthercatPlug')]
-__all__ = [name for name in listdir(_base_path) if path.isdir(path.join(_base_path, name)) and name.upper() != "CVS" or name.endswith(".py") and not name.startswith("__")]
-helps = []
-for name in __all__:
- helpfilename = path.join(_base_path, name, "README")
- if path.isfile(helpfilename):
- helps.append(open(helpfilename).readline().strip())
- else:
- helps.append(name)
+