From 11c6092ea0e2aec4c2bc1b7f231fcf810b5e32b7 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 20 Sep 2009 17:42:02 +0200 Subject: [PATCH] [entropy.spm/entropy.const] PortagePlugin: remove etpConst['spm']['cache'] --- docs/TODO | 2 - libraries/entropy/const.py | 1 - .../spm/plugins/interfaces/portage_plugin.py | 56 ++++++++----------- 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/docs/TODO b/docs/TODO index 15c5edda4..d1b4c38b5 100644 --- a/docs/TODO +++ b/docs/TODO @@ -4,8 +4,6 @@ Proposed for Entropy 1.0 (before and after) (requires API changes, perhaps): 1.0_beta1: - - handlePackage, remove revision from returning data - - remove etpConst['spm']['cache'] - removePackage slowness - entropy.client.interfaces.trigger, move Portage code to entropy.spm - entropy.db hookable plugins support (atom/dep validation, db taint, diff --git a/libraries/entropy/const.py b/libraries/entropy/const.py index 69f0c10c1..93e6e8368 100644 --- a/libraries/entropy/const.py +++ b/libraries/entropy/const.py @@ -536,7 +536,6 @@ def const_default_settings(rootdir): 'verbose_cmd': "--verbose", 'nocolor_cmd': "--color=n", 'backend': "portage", # default one - 'cache': {}, 'xpak_entries': { 'description': "DESCRIPTION", 'homepage': "HOMEPAGE", diff --git a/libraries/entropy/spm/plugins/interfaces/portage_plugin.py b/libraries/entropy/spm/plugins/interfaces/portage_plugin.py index 19077efb9..1f42f23ca 100644 --- a/libraries/entropy/spm/plugins/interfaces/portage_plugin.py +++ b/libraries/entropy/spm/plugins/interfaces/portage_plugin.py @@ -130,6 +130,13 @@ class PortagePlugin(SpmPlugin): "match-visible", "minimum-all", "minimum-visible" ] + CACHE = { + 'vartree': {}, + 'binarytree': {}, + 'config': {}, + 'portagetree': {}, + } + class paren_normalize(list): """Take a dependency structure as returned by paren_reduce or use_reduce and generate an equivalent structure that has no redundant lists.""" @@ -1763,49 +1770,34 @@ class PortagePlugin(SpmPlugin): if root is None: root = etpConst['systemroot'] + os.path.sep - if not etpConst['spm']['cache'].has_key('portage'): - etpConst['spm']['cache']['portage'] = {} - if not etpConst['spm']['cache']['portage'].has_key('vartree'): - etpConst['spm']['cache']['portage']['vartree'] = {} - - cached = etpConst['spm']['cache']['portage']['vartree'].get(root) - if cached != None: + cached = PortagePlugin.CACHE['vartree'].get(root) + if cached is not None: return cached try: mytree = self.portage.vartree(root=root) except Exception, e: raise SPMError("SPMError: %s: %s" % (Exception,e,)) - etpConst['spm']['cache']['portage']['vartree'][root] = mytree + PortagePlugin.CACHE['vartree'][root] = mytree return mytree def _get_portage_portagetree(self, root): - if not etpConst['spm']['cache'].has_key('portage'): - etpConst['spm']['cache']['portage'] = {} - if not etpConst['spm']['cache']['portage'].has_key('portagetree'): - etpConst['spm']['cache']['portage']['portagetree'] = {} - - cached = etpConst['spm']['cache']['portage']['portagetree'].get(root) - if cached != None: + cached = PortagePlugin.CACHE['portagetree'].get(root) + if cached is not None: return cached try: mytree = self.portage.portagetree(root=root) except Exception, e: raise SPMError("SPMError: %s: %s" % (Exception,e,)) - etpConst['spm']['cache']['portage']['portagetree'][root] = mytree + PortagePlugin.CACHE['portagetree'][root] = mytree return mytree def _get_portage_binarytree(self, root): - if not etpConst['spm']['cache'].has_key('portage'): - etpConst['spm']['cache']['portage'] = {} - if not etpConst['spm']['cache']['portage'].has_key('binarytree'): - etpConst['spm']['cache']['portage']['binarytree'] = {} - - cached = etpConst['spm']['cache']['portage']['binarytree'].get(root) - if cached != None: + cached = PortagePlugin.CACHE['binarytree'].get(root) + if cached is not None: return cached pkgdir = root+self.portage.settings['PKGDIR'] @@ -1813,27 +1805,25 @@ class PortagePlugin(SpmPlugin): mytree = self.portage.binarytree(root,pkgdir) except Exception, e: raise SPMError("SPMError: %s: %s" % (Exception,e,)) - etpConst['spm']['cache']['portage']['binarytree'][root] = mytree + PortagePlugin.CACHE['binarytree'][root] = mytree return mytree def _get_portage_config(self, config_root, root, use_cache = True): if use_cache: - if not etpConst['spm']['cache'].has_key('portage'): - etpConst['spm']['cache']['portage'] = {} - if not etpConst['spm']['cache']['portage'].has_key('config'): - etpConst['spm']['cache']['portage']['config'] = {} - - cached = etpConst['spm']['cache']['portage']['config'].get((config_root,root)) - if cached != None: + cached = PortagePlugin.CACHE['config'].get((config_root,root)) + if cached is not None: return cached try: - mysettings = self.portage.config(config_root = config_root, target_root = root, config_incrementals = self.portage_const.INCREMENTALS) + mysettings = self.portage.config(config_root = config_root, + target_root = root, + config_incrementals = self.portage_const.INCREMENTALS) except Exception, e: raise SPMError("SPMError: %s: %s" % (Exception,e,)) if use_cache: - etpConst['spm']['cache']['portage']['config'][(config_root,root)] = mysettings + PortagePlugin.CACHE['config'][(config_root,root)] = mysettings + return mysettings def _get_package_use_file(self):