30 lines
753 B
Cython
30 lines
753 B
Cython
cdef class CommonMethod:
|
|
def __init__(CommonMethod self, str method_name):
|
|
self.method_name = method_name
|
|
self.module_names = []
|
|
self.modules = []
|
|
|
|
def link_module(CommonMethod self, Module module):
|
|
self.module_names.append(module._name)
|
|
self.modules.append(module)
|
|
|
|
def unlink_module(CommonMethod self, module_name):
|
|
i = self.module_names.index(module_name)
|
|
|
|
del self.module_names[i]
|
|
del self.modules[i]
|
|
|
|
def __call__(CommonMethod self, *args):
|
|
return_values = []
|
|
|
|
for module in self.modules:
|
|
return_values.append(getattr(module, self.method_name).__call__(*args))
|
|
|
|
return return_values
|
|
|
|
def __repr__(self):
|
|
return "CommonMethod(name=%s)" %(self.method_name)
|
|
|
|
@property
|
|
def _name(self):
|
|
return repr(self)
|