diff options
Diffstat (limited to 'portato/backend')
-rw-r--r-- | portato/backend/package.py | 16 | ||||
-rw-r--r-- | portato/backend/portage/atom.py | 16 | ||||
-rw-r--r-- | portato/backend/portage/package.py | 2 | ||||
-rw-r--r-- | portato/backend/portage/system.py | 29 |
4 files changed, 39 insertions, 24 deletions
diff --git a/portato/backend/package.py b/portato/backend/package.py index 34cdbe4..56b910d 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -27,6 +27,7 @@ class Package (_Package): @type cpv: string (cat/pkg-ver)""" self._cpv = cpv + self._slot = None def __repr__ (self): return "<Package '%s' @0x%x>" % (self._cpv, id(self)) @@ -154,15 +155,26 @@ class Package (_Package): @returns: category/package. @rtype: string""" - return self.get_category()+"/"+self.get_name() + return "/".join(self.get_category(), self.get_name()) + def get_slot (self): + """Returns the slot. + + @returns: Slot + @rtype: string""" + + if self._slot is None: + self._slot = self.get_package_settings("SLOT") + + return self._slot + def get_slot_cp (self): """Returns the current cp followed by a colon and the slot-number. @returns: cp:slot @rtype: string""" - return ("%s:%s" % (self.get_cp(), self.get_package_settings("SLOT"))) + return ":".join(self.get_cp(), self.get_slot()) def get_package_path(self): """Returns the path to where the ChangeLog, Manifest, .ebuild files reside. diff --git a/portato/backend/portage/atom.py b/portato/backend/portage/atom.py new file mode 100644 index 0000000..78ec02e --- /dev/null +++ b/portato/backend/portage/atom.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# +# File: portato/backend/portage/atom.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2006-2009 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +from portage.dep import Atom + +class PortageAtom (Atom): + pass diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index b34e3ef..7dbefb7 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -299,5 +299,5 @@ class PortagePackage (Package): def matches (self, criterion): # cpv_matches needs explicit slot info - scpv = "%s:%s" % (self.get_cpv(), self.get_package_settings("SLOT")) + scpv = ":".join(self.get_cpv(), self.get_slot()) return system.cpv_matches(scpv, criterion) diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index 3aaa060..34d2b5c 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -172,24 +172,6 @@ class PortageSystem (SystemInterface): else: return lambda x: True - def geneticize_list (self, list_of_packages, only_cpv = False): - """Convertes a list of cpv's into L{backend.Package}s. - - @param list_of_packages: the list of packages - @type list_of_packages: string[] - @param only_cpv: do nothing - return the passed list - @type only_cpv: boolean - @returns: converted list - @rtype: PortagePackage[] - """ - - if not only_cpv: - return [self.new_package(x) for x in list_of_packages] - elif not isinstance(list_of_packages, list): - return list(list_of_packages) - else: - return list_of_packages - def get_global_settings (self, key): return self.settings.global_settings[key] @@ -227,7 +209,12 @@ class PortageSystem (SystemInterface): return self.setmap[pkgSet]() def find_packages (self, key = "", pkgSet = SystemInterface.SET_ALL, masked = False, with_version = True, only_cpv = False): - return self.geneticize_list(self._get_set(pkgSet).find(key, masked, with_version, only_cpv), only_cpv or not with_version) + result = self._get_set(pkgSet).find(key, masked, with_version, only_cpv) + + if (not only_cpv) and with_version: + result = map(self.new_package, result) + + return result def list_categories (self, name = None): categories = self.settings.global_settings.categories @@ -285,9 +272,9 @@ class PortageSystem (SystemInterface): if len(inst) > 1: myslots = set() for i in inst: # get the slots of the installed packages - myslots.add(i.get_package_settings("SLOT")) + myslots.add(i.get_slot()) - myslots.add(best_p.get_package_settings("SLOT")) # add the slot of the best package in portage + myslots.add(best_p.get_slot()) # add the slot of the best package in portage for slot in myslots: crit = "%s:%s" % (p, slot) append(crit, self.find_best_match(crit), inst) |