[yum-git] Branch 'yum-3_2_X' - 7 commits - cli.py output.py yumcommands.py yum/comps.py yum/__init__.py yum/misc.py
James Antill
james at linux.duke.edu
Tue Sep 23 02:02:53 UTC 2008
cli.py | 9 +--
output.py | 7 +-
yum/__init__.py | 2
yum/comps.py | 138 ++++++++++++++++++++++++++++++++++++++------------------
yum/misc.py | 1
yumcommands.py | 3 +
6 files changed, 105 insertions(+), 55 deletions(-)
New commits:
commit 0b1cd194966a0e1a8d4595f55284bd411d1746f9
Author: James Antill <james at and.org>
Date: Mon Sep 22 21:46:04 2008 -0400
Use ui_name and ui_description in displayPkgsInGroups
diff --git a/output.py b/output.py
index 0e910d9..047576e 100644
--- a/output.py
+++ b/output.py
@@ -579,15 +579,14 @@ class YumOutput:
columns=columns)
def displayPkgsInGroups(self, group):
- mylang = get_my_lang_code()
- print _('\nGroup: %s') % group.nameByLang(mylang)
+ print _('\nGroup: %s') % group.ui_name
verb = self.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)
pkg_names2pkgs = None
if verb:
pkg_names2pkgs = self._group_names2aipkgs(group.packages)
- if group.descriptionByLang(mylang) != "":
- print _(' Description: %s') % to_unicode(group.descriptionByLang(mylang))
+ if group.ui_description:
+ print _(' Description: %s') % to_unicode(group.ui_description)
sections = ((_(' Mandatory Packages:'), group.mandatory_packages),
(_(' Default Packages:'), group.default_packages),
commit 4fdae031cce756a95bf2beaae5a13d50280a8fe7
Author: James Antill <james at and.org>
Date: Mon Sep 22 21:45:43 2008 -0400
Add ui_description for ease of use
diff --git a/yum/comps.py b/yum/comps.py
index 619a4fb..ee9f187 100755
--- a/yum/comps.py
+++ b/yum/comps.py
@@ -51,6 +51,11 @@ class CompsObj(object):
""" Return the "name" of the object for the current locale. """
return self.nameByLang(get_my_lang_code())
+ @property
+ def ui_description(self):
+ """ Return the "description" of the object for the current locale. """
+ return self.descriptionByLang(get_my_lang_code())
+
def __cmp__(self, other):
if other is None:
return 1
commit e9530f3be658bbf7b5db134e6fcec180c6ae92d1
Author: James Antill <james at and.org>
Date: Mon Sep 22 21:34:14 2008 -0400
Have doGroupLists returned "user sorted data"
diff --git a/yum/__init__.py b/yum/__init__.py
index 29c57c2..cb86717 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1804,7 +1804,7 @@ class YumBase(depsolve.Depsolve):
else:
available.append(grp)
- return installed, available
+ return sorted(installed), sorted(available)
def groupRemove(self, grpid):
commit 1ccc549348e8d276f62b8b326d90054a18b59efa
Author: James Antill <james at and.org>
Date: Mon Sep 22 21:12:15 2008 -0400
Do the Remove only TS thing for GroupRemove
diff --git a/yumcommands.py b/yumcommands.py
index 0e07cd3..3a8ad88 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -409,6 +409,9 @@ class GroupRemoveCommand(GroupCommand):
def needTs(self, base, basecmd, extcmds):
return False
+ def needTsRemove(self, base, basecmd, extcmds):
+ return True
+
class GroupInfoCommand(GroupCommand):
def getNames(self):
return ['groupinfo']
commit 6be024406dc4d862c1e43975fa7754f098cc04ff
Author: James Antill <james at and.org>
Date: Mon Sep 22 20:57:26 2008 -0400
Fix the sorting of grouplist to obey display_order, just use the group cmp
diff --git a/cli.py b/cli.py
index cf0b186..c6b1420 100644
--- a/cli.py
+++ b/cli.py
@@ -816,21 +816,20 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
uservisible=0
installed, available = self.doGroupLists(uservisible=uservisible)
- mylang = yum.misc.get_my_lang_code()
if len(installed) > 0:
self.verbose_logger.log(yum.logginglevels.INFO_2,
_('Installed Groups:'))
- for group in sorted(installed, key=lambda x: x.nameByLang(mylang)):
+ for group in installed:
self.verbose_logger.log(yum.logginglevels.INFO_2, ' %s',
- group.nameByLang(mylang))
+ group.ui_name)
if len(available) > 0:
self.verbose_logger.log(yum.logginglevels.INFO_2,
_('Available Groups:'))
- for group in sorted(available, key=lambda x: x.nameByLang(mylang)):
+ for group in available:
self.verbose_logger.log(yum.logginglevels.INFO_2, ' %s',
- group.nameByLang(mylang))
+ group.ui_name)
return 0, [_('Done')]
commit 04fcb38d8f7b94b6cd2fbf966ae635dab69e2dc6
Author: James Antill <james at and.org>
Date: Mon Sep 22 20:56:28 2008 -0400
Add return_categories() to comps object.
Add nameByLang/descriptionByLang to category objects.
Add ui_name to groups/categories, using the current locale's name.
Add __cmp__ function to group/categories.
diff --git a/yum/comps.py b/yum/comps.py
index f36b678..619a4fb 100755
--- a/yum/comps.py
+++ b/yum/comps.py
@@ -25,7 +25,7 @@ from Errors import CompsException
# switch all compsexceptions to grouperrors after api break
import fnmatch
import re
-from yum.misc import to_unicode
+from yum.misc import to_unicode, get_my_lang_code
lang_attr = '{http://www.w3.org/XML/1998/namespace}lang'
@@ -38,42 +38,29 @@ def parse_boolean(strng):
def parse_number(strng):
return int(strng)
-class Group(object):
- def __init__(self, elem=None):
- self.user_visible = True
- self.default = False
- self.selected = False
- self.name = ""
- self.description = ""
- self.translated_name = {}
- self.translated_description = {}
- self.mandatory_packages = {}
- self.optional_packages = {}
- self.default_packages = {}
- self.conditional_packages = {}
- self.langonly = None ## what the hell is this?
- self.groupid = None
- self.display_order = 1024
- self.installed = False
- self.toremove = False
-
+class CompsObj(object):
+ """ Group/Category helper object. """
- if elem:
- self.parse(elem)
-
+ # Could be the same as ui_name?
def __str__(self):
+ """ Return the "name" of the object for the C locale. """
return self.name
+
+ @property
+ def ui_name(self):
+ """ Return the "name" of the object for the current locale. """
+ return self.nameByLang(get_my_lang_code())
- def _packageiter(self):
- # Gah, FIXME: real iterator/class
- lst = self.mandatory_packages.keys() + \
- self.optional_packages.keys() + \
- self.default_packages.keys() + \
- self.conditional_packages.keys()
-
- return lst
-
- packages = property(_packageiter)
+ def __cmp__(self, other):
+ if other is None:
+ return 1
+
+ if self.display_order > other.display_order:
+ return 1
+ if self.display_order < other.display_order:
+ return -1
+
+ return cmp(self.ui_name, other.ui_name)
def _expand_languages(self, lang):
import gettext
@@ -98,13 +85,48 @@ class Group(object):
return to_unicode(self.name)
-
def descriptionByLang(self, lang):
for langcode in self._expand_languages(lang):
if self.translated_description.has_key(langcode):
return to_unicode(self.translated_description[langcode])
return to_unicode(self.description)
+
+class Group(CompsObj):
+ """ Group object parsed from group data in each repo. and merged. """
+
+ def __init__(self, elem=None):
+ self.user_visible = True
+ self.default = False
+ self.selected = False
+ self.name = ""
+ self.description = ""
+ self.translated_name = {}
+ self.translated_description = {}
+ self.mandatory_packages = {}
+ self.optional_packages = {}
+ self.default_packages = {}
+ self.conditional_packages = {}
+ self.langonly = None ## what the hell is this?
+ self.groupid = None
+ self.display_order = 1024
+ self.installed = False
+ self.toremove = False
+
+ if elem:
+ self.parse(elem)
+
+ def _packageiter(self):
+ # Gah, FIXME: real iterator/class
+ lst = self.mandatory_packages.keys() + \
+ self.optional_packages.keys() + \
+ self.default_packages.keys() + \
+ self.conditional_packages.keys()
+
+ return lst
+
+ packages = property(_packageiter)
+
def parse(self, elem):
for child in elem:
@@ -247,11 +269,11 @@ class Group(object):
msg += """ </group>"""
return msg
-
-
-class Category(object):
+class Category(CompsObj):
+ """ Category object parsed from group data in each repo. and merged. """
+
def __init__(self, elem=None):
self.name = ""
self.categoryid = None
@@ -264,9 +286,6 @@ class Category(object):
if elem:
self.parse(elem)
- def __str__(self):
- return self.name
-
def _groupiter(self):
return self._groups.keys()
@@ -352,6 +371,7 @@ class Category(object):
return msg
+
class Comps(object):
def __init__(self, overwrite_groups=False):
self._groups = {}
@@ -363,10 +383,11 @@ class Comps(object):
def __sort_order(self, item1, item2):
+ """ This sorts for machines, so is the same in all locales. """
if item1.display_order > item2.display_order:
return 1
elif item1.display_order == item2.display_order:
- return 0
+ return cmp(item1.name, item2.name)
else:
return -1
@@ -379,13 +400,10 @@ class Comps(object):
cats = self._categories.values()
cats.sort(self.__sort_order)
return cats
-
groups = property(get_groups)
categories = property(get_categories)
-
-
def has_group(self, grpid):
exists = self.return_groups(grpid)
@@ -427,6 +445,33 @@ class Comps(object):
return returns.values()
+ # This is close to returnPackages() etc. API ... need to std. these names
+ # the above return_groups uses different, but equal, API.
+ def return_categories(self, pattern, ignore_case=True):
+ """return all categories which match either by glob or exact match"""
+ returns = {}
+
+ for item in pattern.split(','):
+ item = item.strip()
+ if self._categories.has_key(item):
+ cat = self._categories[item]
+ returns[cat.categoryid] = cat
+ continue
+
+ if not ignore_case:
+ match = re.compile(fnmatch.translate(item)).match
+ else:
+ match = re.compile(fnmatch.translate(item), flags=re.I).match
+
+ for cat in self.categories:
+ names = [ cat.name, cat.categoryid ]
+ names.extend(cat.translated_name.values())
+ for name in names:
+ if match(name):
+ returns[cat.categoryid] = cat
+
+ return returns.values()
+
def add_group(self, group):
if self._groups.has_key(group.groupid):
thatgroup = self._groups[group.groupid]
commit 3d2f8244b4e281a621f81a10492ddda960ae2568
Author: James Antill <james at and.org>
Date: Mon Sep 22 17:41:59 2008 -0400
Minor fix to get_my_lang_code, no need to import locale as it already is
diff --git a/yum/misc.py b/yum/misc.py
index 2a64bea..c9ae758 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -732,7 +732,6 @@ def to_str(obj):
return obj
def get_my_lang_code():
- import locale
mylang = locale.getlocale()
if mylang == (None, None): # odd :)
mylang = 'C'
More information about the Yum-cvs-commits
mailing list