Package entropy :: Package client :: Package interfaces :: Module db

Source Code for Module entropy.client.interfaces.db

 1  # -*- coding: utf-8 -*- 
 2  """ 
 3   
 4      @author: Fabio Erculiani <lxnay@sabayonlinux.org> 
 5      @contact: lxnay@sabayonlinux.org 
 6      @copyright: Fabio Erculiani 
 7      @license: GPL-2 
 8   
 9      B{Entropy Package Manager Client EntropyRepository plugin code}. 
10   
11  """ 
12  from entropy.const import const_debug_write 
13  from entropy.db.skel import EntropyRepositoryPlugin 
14   
15 -class ClientEntropyRepositoryPlugin(EntropyRepositoryPlugin):
16
17 - def __init__(self, client_interface, metadata = None):
18 """ 19 Entropy client-side repository EntropyRepository Plugin class. 20 This class will be instantiated and automatically added to 21 EntropyRepository instances generated by Entropy Client. 22 23 @param client_interface: Entropy Client interface instance 24 @type client_interface: entropy.client.interfaces.Client class 25 @param metadata: any dict form metadata map (key => value) 26 @type metadata: dict 27 """ 28 EntropyRepositoryPlugin.__init__(self) 29 self._client = client_interface 30 if metadata is None: 31 self._metadata = {} 32 else: 33 self._metadata = metadata 34 35 # make sure we set client_repo metadata to True, this indicates 36 # EntropyRepository that we are a client-side repository 37 # Of course, it shouldn't make any diff to not set this, but we 38 # really want to make sure it's always enforced. 39 self._metadata['client_repo'] = True
40
41 - def get_id(self):
42 return "__client__"
43
44 - def get_metadata(self):
45 return self._metadata
46
47 - def add_plugin_hook(self, entropy_repository_instance):
48 const_debug_write(__name__, 49 "ClientEntropyRepositoryPlugin: calling add_plugin_hook => %s" % ( 50 self,) 51 ) 52 53 out_intf = self._metadata.get('output_interface') 54 if out_intf is not None: 55 entropy_repository_instance.updateProgress = out_intf.updateProgress 56 entropy_repository_instance.askQuestion = out_intf.askQuestion 57 58 return 0
59