config: Move _prune_incremental to helper
authorSebastian Luther <SebastianLuther@gmx.de>
Tue, 24 Aug 2010 08:49:48 +0000 (10:49 +0200)
committerZac Medico <zmedico@gentoo.org>
Tue, 24 Aug 2010 13:13:39 +0000 (06:13 -0700)
pym/portage/package/ebuild/_config/helper.py
pym/portage/package/ebuild/config.py

index 00e2dfabc5822452b6a6d449cad988ab9c6c13ef..c29b95e14b5180a96128e0d3cdecd4c4a702c696 100644 (file)
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = (
-       'ordered_by_atom_specificity',
+       'ordered_by_atom_specificity', 'prune_incremental',
 )
 
 from portage.dep import best_match_to_list
@@ -40,3 +40,22 @@ def ordered_by_atom_specificity(cpdict, pkg):
                results.reverse()
 
        return results
+
+def prune_incremental(split):
+       """
+       Prune off any parts of an incremental variable that are
+       made irrelevant by the latest occuring * or -*. This
+       could be more aggressive but that might be confusing
+       and the point is just to reduce noise a bit.
+       """
+       for i, x in enumerate(reversed(split)):
+               if x == '*':
+                       split = split[-i-1:]
+                       break
+               elif x == '-*':
+                       if i == 0:
+                               split = []
+                       else:
+                               split = split[-i:]
+                       break
+       return split
index ffff8c02968f7c8c2ed77205e7465119203619b6..a031314bf3eaf8ce1af8167840fb62f9fda7ac16 100644 (file)
@@ -49,7 +49,7 @@ from portage.versions import catpkgsplit, catsplit, cpv_getkey
 
 from portage.package.ebuild._config.features_set import features_set
 from portage.package.ebuild._config.LicenseManager import LicenseManager
-from portage.package.ebuild._config.helper import ordered_by_atom_specificity
+from portage.package.ebuild._config.helper import ordered_by_atom_specificity, prune_incremental
 
 if sys.hexversion >= 0x3000000:
        basestring = str
@@ -2158,25 +2158,6 @@ class config(object):
                        # env_d will be None if profile.env doesn't exist.
                        self.configdict["env.d"].update(env_d)
 
-       def _prune_incremental(self, split):
-               """
-               Prune off any parts of an incremental variable that are
-               made irrelevant by the latest occuring * or -*. This
-               could be more aggressive but that might be confusing
-               and the point is just to reduce noise a bit.
-               """
-               for i, x in enumerate(reversed(split)):
-                       if x == '*':
-                               split = split[-i-1:]
-                               break
-                       elif x == '-*':
-                               if i == 0:
-                                       split = []
-                               else:
-                                       split = split[-i:]
-                               break
-               return split
-
        def regenerate(self,useonly=0,use_cache=1):
                """
                Regenerate settings
@@ -2222,7 +2203,7 @@ class config(object):
                        mysplit = []
                        for curdb in mydbs:
                                mysplit.extend(curdb.get('ACCEPT_LICENSE', '').split())
-                       mysplit = self._prune_incremental(mysplit)
+                       mysplit = prune_incremental(mysplit)
                        accept_license_str = ' '.join(mysplit)
                        self.configlist[-1]['ACCEPT_LICENSE'] = accept_license_str
                        self._license_manager.set_accept_license_str(accept_license_str)
@@ -2235,7 +2216,7 @@ class config(object):
                        mysplit = []
                        for curdb in mydbs:
                                mysplit.extend(curdb.get('ACCEPT_PROPERTIES', '').split())
-                       mysplit = self._prune_incremental(mysplit)
+                       mysplit = prune_incremental(mysplit)
                        self.configlist[-1]['ACCEPT_PROPERTIES'] = ' '.join(mysplit)
                        if tuple(mysplit) != self._accept_properties:
                                self._accept_properties = tuple(mysplit)