source: syncer/trunk/fuentes/syncer.install/usr/lib/syncer/plugins/communicate.py @ 4039

Last change on this file since 4039 was 4039, checked in by mabarracus, 3 years ago

First release

File size: 1.1 KB
Line 
1from lib.SyncerTypes import *
2
3class handler_communicate(IPlugin):
4    def init_plugin(self):
5        self.typeplug = 'comm'
6        self.params = ['type_block']
7        self.is_blocker = True
8
9    def process(self,*args,**kwargs):
10        params=kwargs['params']
11        debug('Launch comm {}'.format(params['type_block']))
12        prev_value = kwargs['transid'] - 1
13        post_value = kwargs['transid'] + 1
14        the_plugin1=self.syncer.get_pluginobj_from_transid(prev_value)
15        the_plugin2 = self.syncer.get_pluginobj_from_transid(post_value)
16        pl1out=the_plugin1.output(transid=prev_value)['output']
17
18        copy_args = 0
19        copy_list = []
20        if len(the_plugin2.params) != len(pl1out):
21            copy_args = len(the_plugin2.params) - len(pl1out)
22
23        iterparam=iter(pl1out)
24        for param in the_plugin2.params:
25            if copy_args > 0:
26                copy_list.append(the_plugin2.data_input[post_value][param])
27                copy_args-=1
28            else:
29                copy_list.append(next(iterparam))
30
31        the_plugin2.input(trans_id=post_value,params=copy_list)
32        return True,str(params['type_block'])
Note: See TracBrowser for help on using the repository browser.