Explorar el Código

Debug Metaclass to get child from Plugin Class

m.orban hace 8 años
padre
commit
e4f0bd2358
Se han modificado 1 ficheros con 15 adiciones y 10 borrados
  1. 15
    10
      lodel/plugin/plugins.py

+ 15
- 10
lodel/plugin/plugins.py Ver fichero

@@ -163,20 +163,20 @@ class MetaPlugType(type):
163 163
         if len(bases) == 1 and bases[0] == object:
164 164
             print("Dropped : ", name, bases)
165 165
             return
166
-        list_name= [cls._name__ for cls in plugin_types(self)] 
167
-        if self.name is in list_name:
168
-            return
169
-        else:
170
-            plug_type_register(self)
166
+        self.__register_types()
167
+        #list_name= [cls.__name__ for cls in __all_ptypes] 
168
+        #if self.name in list_name:
169
+        #    return
170
+        #else:
171
+        #    plug_type_register(self)
172
+
173
+    def __register_types(self):
174
+        plug_type_register(self)
171 175
 
172 176
 def plug_type_register(cls):
173
-    __all__ptypes.append(cls)
177
+    __all_ptypes.append(cls)
174 178
     logger.info("New child class registered : %s" % cls.__name__)
175 179
 
176
-##@brief Return a list of child Class Plugin
177
-@classmethod
178
-def plugin_types(cls):
179
-    return cls.__all_ptypes
180 180
 
181 181
 ##@brief Handle plugins
182 182
 #
@@ -639,6 +639,11 @@ file : '%s'. Running discover again..." % DISCOVER_CACHE_FILENAME)
639 639
         cls._plugin_list = infos['plugins']
640 640
         return cls._plugin_list
641 641
 
642
+    ##@brief Return a list of child Class Plugin
643
+    @classmethod
644
+    def plugin_types(cls):
645
+        return cls.__all_ptypes
646
+
642 647
     ##@brief Attempt to open and load plugin discover cache
643 648
     #@return discover cache
644 649
     #@throw PluginError when open or load fails

Loading…
Cancelar
Guardar