summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-04-08 20:34:50 +0000
committerZac Medico <zmedico@gentoo.org>2009-04-08 20:34:50 +0000
commitd9f6b91f5db476a6521968cd28c47b12ffee1627 (patch)
treef3ad464f939d1167e90d3ddd00f1bb18fc55dbe2
parent3e20a783357886cb187eb33fe58e9dcab436f7bc (diff)
downloadportage-d9f6b91f5db476a6521968cd28c47b12ffee1627.tar.gz
portage-d9f6b91f5db476a6521968cd28c47b12ffee1627.tar.bz2
portage-d9f6b91f5db476a6521968cd28c47b12ffee1627.zip
Add UseFlagDisplay.sort_combined and sort_separated attributes that can be
passed directly as key parameters to list.sort(). svn path=/main/trunk/; revision=13303
-rw-r--r--pym/_emerge/__init__.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 11ad3fae1..5c7f62d3c 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -9252,15 +9252,16 @@ class UseFlagDisplay(object):
s = '(%s)' % s
return s
- @classmethod
- def cmp_combined(cls, a, b):
+ def _cmp_combined(a, b):
"""
Sort by name, combining enabled and disabled flags.
"""
return (a.name > b.name) - (a.name < b.name)
- @classmethod
- def cmp_separated(cls, a, b):
+ sort_combined = cmp_sort_key(_cmp_combined)
+ del _cmp_combined
+
+ def _cmp_separated(a, b):
"""
Sort by name, separating enabled flags from disabled flags.
"""
@@ -9269,6 +9270,9 @@ class UseFlagDisplay(object):
return enabled_diff
return (a.name > b.name) - (a.name < b.name)
+ sort_separated = cmp_sort_key(_cmp_separated)
+ del _cmp_separated
+
class PollSelectAdapter(PollConstants):
"""
@@ -13687,9 +13691,9 @@ def action_info(settings, trees, myopts, myfiles):
for f in use_disabled.get(varname, []):
flags.append(UseFlagDisplay(f, False, f in forced_flags))
if alphabetical_use:
- flags.sort(key=cmp_sort_key(UseFlagDisplay.cmp_combined))
+ flags.sort(key=UseFlagDisplay.sort_combined)
else:
- flags.sort(key=cmp_sort_key(UseFlagDisplay.cmp_separated))
+ flags.sort(key=UseFlagDisplay.sort_separated)
print '%s="%s"' % (varname, ' '.join(str(f) for f in flags)),
print