diff options
-rwxr-xr-x | portato.py | 4 | ||||
-rw-r--r-- | portato/backend/__init__.py | 19 | ||||
-rw-r--r-- | portato/backend/package.py | 14 | ||||
-rw-r--r-- | portato/backend/portage_helper.py | 30 |
4 files changed, 40 insertions, 27 deletions
@@ -5,7 +5,7 @@ # File: portato.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006 René 'Necoro' Neumann +# Copyright (C) 2006-2007 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. @@ -18,7 +18,7 @@ import sys if __name__ == "__main__": if len(sys.argv) > 1 and sys.argv[1] in ("--help","--version","-h","-v"): print """Portato %s -Copyright (C) 2006 René 'Necoro' Neumann +Copyright (C) 2006-2007 René 'Necoro' Neumann This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. diff --git a/portato/backend/__init__.py b/portato/backend/__init__.py index 5ee2e2a..1e7066f 100644 --- a/portato/backend/__init__.py +++ b/portato/backend/__init__.py @@ -3,7 +3,7 @@ # File: portato/backend/__init__.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006 René 'Necoro' Neumann +# Copyright (C) 2006-2007 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. @@ -17,12 +17,23 @@ from threading import Lock import portage class PortageSettings: + """Encapsulation of the portage settings. + + @ivar settings: portage settings + @ivar settingslock: a simple Lock + @ivar trees: a dictionary of the trees + @ivar porttree: shortcut to C{trees[root]["porttree"]} + @ivar vartree: shortcut to C{trees[root]["vartree"]} + @ivar virtuals: shortcut to C{trees[root]["virtuals"]}""" def __init__ (self): + """Initializes the instance. Calls L{load()}.""" self.settingslock = Lock() self.load() def load(self): + """(Re)loads the portage settings and sets the variables.""" + kwargs = {} for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")): kwargs[k] = os.environ.get(envvar, None) @@ -42,10 +53,13 @@ class PortageSettings: self.porttree = self.trees[root]["porttree"] self.vartree = self.trees[root]["vartree"] self.virtuals = self.trees[root]["virtuals"] + + portage.settings = None # we use our own one ... # portage tree vars portage_settings = PortageSettings() +# for the moment ;) settingslock = portage_settings.settingslock settings = portage_settings.settings trees = portage_settings.trees @@ -54,8 +68,7 @@ vartree = portage_settings.vartree virtuals = portage_settings.virtuals # this is set to "var/lib/portage/world" by default - so we add the leading / -portage.WORLD_FILE = portage.settings["ROOT"]+portage.WORLD_FILE -portage.settings = None # we use our own one ... +portage.WORLD_FILE = portage_settings.settings["ROOT"]+portage.WORLD_FILE # import our packages from exceptions import * diff --git a/portato/backend/package.py b/portato/backend/package.py index 8aa1216..15dd59a 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -3,7 +3,7 @@ # File: portato/backend/package.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006 René 'Necoro' Neumann +# Copyright (C) 2006-2007 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. @@ -52,11 +52,15 @@ class Package: self._status = None def is_installed(self): - """Returns true if this package is installed (merged)""" + """Returns true if this package is installed (merged) + @rtype: boolean""" + return portage_settings.vartree.dbapi.cpv_exists(self._cpv) def is_overlay(self): - """Returns true if the package is in an overlay.""" + """Returns true if the package is in an overlay. + @rtype: boolean""" + dir,ovl = portage_settings.porttree.dbapi.findname2(self._cpv) return ovl != self._settings["PORTDIR"] @@ -192,8 +196,8 @@ class Package: i_flags = self.get_installed_use_flags() for f in self.get_new_use_flags(): - if flags.invert_flag(f) in i_flags: - i_flags.remove(flags.invert_flag(f)) + if flags.invert_use_flag(f) in i_flags: + i_flags.remove(flags.invert_use_flag(f)) elif f not in i_flags: i_flags.append(f) diff --git a/portato/backend/portage_helper.py b/portato/backend/portage_helper.py index 188d512..7fc6c34 100644 --- a/portato/backend/portage_helper.py +++ b/portato/backend/portage_helper.py @@ -3,7 +3,7 @@ # File: portato/backend/portage_helper.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006 René 'Necoro' Neumann +# Copyright (C) 2006-2007 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. @@ -36,7 +36,7 @@ def find_lambda (name): return lambda x: True def geneticize_list (list_of_packages): - """Convertes a list of gentoolkit.Packages into L{backend.Package}s. + """Convertes a list of cpv's into L{backend.Package}s. @param list_of_packages: the list of packages @type list_of_packages: list of gentoolkit.Packages @@ -46,7 +46,13 @@ def geneticize_list (list_of_packages): return [package.Package(x) for x in list_of_packages] def find_best (list): + """Returns the best package out of a list of packages. + @param list: the list of packages to select from + @type list: string[] + @returns: the best package + @rtype: backend.Package""" + return package.Package(portage.best(list)) def find_best_match (search_key, only_installed = False): @@ -311,27 +317,18 @@ def update_world (newuse = False, deep = False): packages = [] for line in world: line = line.strip() - if not len(line): continue # empty line - if line[0] == "#": continue + if len(line) == 0: continue # empty line + if line[0] == "#": continue # comment packages.append(line) world.close() + # append system packages sys = portage_settings.settings.packages for x in sys: - if x[0] == "*": + if x[0] == "*": # some packages are stored with a '*' at the front - ignore it x = x[1:] packages.append(x.strip()) - # Remove everything that is package.provided from our list - # This is copied from emerge.getlist() - #for atom in packages[:]: - # for expanded_atom in portage.flatten(portage.dep_virtual([atom], settings)): - # mykey = portage.dep_getkey(expanded_atom) - # if mykey in settings.pprovideddict and portage.match_from_list(expanded_atom, settings.pprovideddict[mykey]): - # packages.remove(atom) - # break - - def get_new_packages (packages): new_packages = [] for p in packages: @@ -352,7 +349,6 @@ def update_world (newuse = False, deep = False): return new_packages - checked = [] updating = [] raw_checked = [] @@ -380,7 +376,7 @@ def update_world (newuse = False, deep = False): appended = True p = old - if newuse and p.is_in_system(): # there is no use to check newuse for a package which is not existing anymore in portage :) + if newuse and p.is_in_system(): # there is no use to check newuse for a package which is not existing in portage anymore :) new_iuse = set(p.get_all_use_flags(installed = False)) # IUSE in the ebuild old_iuse = set(p.get_all_use_flags(installed = True)) # IUSE in the vardb |