Imported core, m, ag and serial for refactoring
This commit is contained in:
parent
6f28ac0382
commit
5baa9b75d0
25 changed files with 918 additions and 4 deletions
30
ag/ag.CommonMethod.pyx
Normal file
30
ag/ag.CommonMethod.pyx
Normal file
|
@ -0,0 +1,30 @@
|
|||
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)
|
Loading…
Add table
Add a link
Reference in a new issue