Skip to content
Snippets Groups Projects
Commit bb0ddc99 authored by florent's avatar florent
Browse files

Register Entity classes in modules from which they are imported

	 * src/dynamic_graph/entity.py.
parent 2caff345
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
"""
import wrap, signal_base
entityList = []
entityClassNameList = []
def initEntity(self, name):
"""
......@@ -13,9 +13,9 @@ def initEntity(self, name):
"""
Entity.__init__(self, self.class_name, name)
def updateEntityClasses():
entityTypeList = wrap.factory_get_entity_class_list()
for e in entityTypeList:
def updateEntityClasses(dictionary):
cxx_entityList = wrap.factory_get_entity_class_list()
for e in filter(lambda x: not x in entityClassNameList, cxx_entityList):
class metacls(type):
def __new__(mcs, name, bases, dict):
return type.__new__(mcs, name, bases, dict)
......@@ -24,11 +24,12 @@ def updateEntityClasses():
a = metacls(e, (Entity,), {})
# Store class name in class member
a.class_name = e
print ("new class %s"%e)
# set class constructor
setattr(a, '__init__', initEntity)
# Store new class in dictionary with class name
globals()[e] = a
dictionary[e] = a
# Store class name in local list
entityClassNameList.append(e)
class Entity (object) :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment