diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2008-07-09 23:24:18 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2008-07-09 23:24:18 +0200 |
commit | b166a860bc1d645208b6ecab5270b64fca34188b (patch) | |
tree | bed4d3025498d668f88fdb5ab07949f9b3890e27 | |
parent | 107c4cc0c8f0039224505d29707ccc7eda4f5afb (diff) | |
parent | c592c0a400099e442508ec09284e188d03fb5444 (diff) | |
download | portato-b166a860bc1d645208b6ecab5270b64fca34188b.tar.gz portato-b166a860bc1d645208b6ecab5270b64fca34188b.tar.bz2 portato-b166a860bc1d645208b6ecab5270b64fca34188b.zip |
Merged in the portage-2.2 branch
Diffstat (limited to '')
-rw-r--r-- | etc/portato.cfg | 5 | ||||
-rw-r--r-- | portato/backend/portage/package.py | 2 | ||||
-rw-r--r-- | portato/backend/portage/sets.py | 145 | ||||
-rw-r--r-- | portato/backend/portage/system.py | 180 | ||||
-rw-r--r-- | portato/backend/portage/system_22.py | 27 | ||||
-rw-r--r-- | portato/backend/system_interface.py | 22 | ||||
-rw-r--r-- | portato/gui/queue.py | 4 | ||||
-rw-r--r-- | portato/gui/templates/PreferenceWindow.glade | 42 | ||||
-rw-r--r-- | portato/gui/utils.py | 2 | ||||
-rw-r--r-- | portato/gui/windows/main.py | 10 | ||||
-rw-r--r-- | portato/gui/windows/plugin.py | 2 | ||||
-rw-r--r-- | portato/gui/windows/preference.py | 39 | ||||
-rw-r--r-- | portato/helper.py | 2 | ||||
-rw-r--r-- | portato/plugin.py | 2 |
14 files changed, 335 insertions, 149 deletions
diff --git a/etc/portato.cfg b/etc/portato.cfg index ca20fd9..4095c23 100644 --- a/etc/portato.cfg +++ b/etc/portato.cfg @@ -47,6 +47,11 @@ keywordperversion = True maskperversion = True useperversion = False +; the sets which are going to be updated on "update world" +; this is only important for >=portage-2.2 +; values: comma-speparated set-names +updatesets = system, world + # # Frontend section for options common to more than one GUI. # Not all frontends have to support all of the options. diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index 78125ee..351b7e0 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -226,7 +226,7 @@ class PortagePackage (Package): for dep in deps: if dep[0] == '!': # blocking sth - blocked = system.find_packages(dep, "installed") + blocked = system.find_packages(dep, system.SET_INSTALLED) if len(blocked) == 1: # only exact one match allowed to be harmless if blocked[0].get_slot_cp() == self.get_slot_cp(): # blocks in the same slot are harmless continue diff --git a/portato/backend/portage/sets.py b/portato/backend/portage/sets.py new file mode 100644 index 0000000..7984d3d --- /dev/null +++ b/portato/backend/portage/sets.py @@ -0,0 +1,145 @@ +# -*- coding: utf-8 -*- +# +# File: portato/backend/portage/sets.py +# This file is part of the Portato-Project, a graphical portage-frontend. +# +# Copyright (C) 2008 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 __future__ import absolute_import, with_statement + +import re + +import portage +try: + import portage.dep as portage_dep +except ImportError: + import portage_dep + +from .. import system +from ...helper import debug + +class Set(object): + + def get_pkgs(self, key, is_regexp, masked, with_version, only_cpv): + raise NotImplementedError + + def find (self, key, masked = False, with_version = True, only_cpv = False): + if key is None: key = "" + + is_regexp = key == "" or ("*" in key and key[0] not in ("*","=","<",">","~","!")) + + try: + t = self.get_pkgs(key, is_regexp, masked, with_version, only_cpv) + # catch the "ambigous package" Exception + except ValueError, e: + if isinstance(e[0], list): + t = set() + for cp in e[0]: + t.update(self.get_pkgs(cp, is_regexp, masked, with_version, only_cpv)) + else: + raise + + return t + +class FilterSet (Set): + + def get_list(self): + raise NotImplementedError + + def get_pkgs (self, key, is_regexp, masked, with_version, only_cpv): + t = set() + for pkg in self.get_list(): + if is_regexp: + if not re.match(key, pkg, re.I): continue + + if not with_version: + t.add(portage_dep.dep_getkey(pkg)) + + t.add(system.find_best_match(pkg, only_cpv = True)) + + return t + +class PortageSet (FilterSet): + def __init__ (self, name): + FilterSet.__init__(self) + debug("Loading portage set '%s'", name) + self.portageSet = system.settings.setsconfig.getSets()[name] + + def get_list(self): + return self.portageSet.getAtoms() + +class SystemSet (FilterSet): + + def get_list(self): + for cp in system.settings.settings.packages: + if cp[0] == "*": yield cp[1:] + +class WorldSet (FilterSet): + + def get_list(self): + with open(portage.WORLD_FILE) as f: + for cp in f: + cp = cp.strip() + if cp and cp[0] != "#": + yield cp + +class InstalledSet (Set): + + def get_pkgs (self, key, is_regexp, masked, with_version, only_cpv): + if is_regexp: + if with_version: + t = system.settings.vartree.dbapi.cpv_all() + else: + t = system.settings.vartree.dbapi.cp_all() + + if key: + t = filter(lambda x: re.match(key, x, re.I), t) + + return set(t) + else: + return set(system.settings.vartree.dbapi.match(key)) + +class TreeSet (Set): + + def get_pkgs (self, key, is_regexp, masked, with_version, only_cpv): + if is_regexp: + if with_version: + t = system.settings.porttree.dbapi.cpv_all() + else: + t = system.settings.porttree.dbapi.cp_all() + + if key: + t = filter(lambda x: re.match(key, x, re.I), t) + + elif masked: + t = system.settings.porttree.dbapi.xmatch("match-all", key) + else: + t = system.settings.porttree.dbapi.match(key) + + return set(t) + +class AllSet (Set): + + def __init__ (self): + Set.__init__(self) + self.tree = TreeSet() + self.installed = InstalledSet() + + def find (self, *args, **kwargs): + return self.tree.find(*args, **kwargs) | self.installed.find(*args, **kwargs) + +class UninstalledSet (Set): + + def __init__ (self): + Set.__init__(self) + self.all = AllSet() + self.installed = InstalledSet() + + def find (self, *args, **kwargs): + return self.all.find(*args, **kwargs) - self.installed.find(*args, **kwargs) + diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index b60db89..4453df7 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -14,9 +14,16 @@ from __future__ import absolute_import, with_statement import re, os, os.path import portage +try: + import portage.dep as portage_dep +except ImportError: + import portage_dep + from collections import defaultdict +import itertools as itt from . import VERSION +from . import sets as syssets from .package import PortagePackage from .settings import PortageSettings from ..system_interface import SystemInterface @@ -37,6 +44,24 @@ class PortageSystem (SystemInterface): self.use_descs = {} self.local_use_descs = defaultdict(dict) + self.setmap = { + self.SET_ALL : syssets.AllSet, + self.SET_INSTALLED : syssets.InstalledSet, + self.SET_UNINSTALLED : syssets.UninstalledSet, + self.SET_TREE : syssets.TreeSet, + "world" : syssets.WorldSet, + "system" : syssets.SystemSet + } + + def has_set_support (self): + return False + + def get_sets (self, description = False): + if description: + return (("world", "The world set."), ("system", "The system set.")) + else: + return ("world", "system") + def get_version (self): return "Portage %s" % portage.VERSION @@ -142,6 +167,8 @@ class PortageSystem (SystemInterface): 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 @@ -159,16 +186,16 @@ class PortageSystem (SystemInterface): t = [] if not only_installed: - pkgSet = "tree" + pkgSet = self.SET_TREE else: - pkgSet = "installed" + pkgSet = self.SET_INSTALLED t = self.find_packages(search_key, pkgSet = pkgSet, masked = masked, with_version = True, only_cpv = True) if VERSION >= (2,1,5): - t += [pkg.get_cpv() for pkg in self.find_packages(search_key, "installed") if not (pkg.is_testing(True) or pkg.is_masked())] + t += [pkg.get_cpv() for pkg in self.find_packages(search_key, self.SET_INSTALLED) if not (pkg.is_testing(True) or pkg.is_masked())] elif not only_installed: # no need to run twice - t += self.find_packages(search_key, "installed", only_cpv=True) + t += self.find_packages(search_key, self.SET_INSTALLED, only_cpv=True) if t: t = unique_array(t) @@ -176,123 +203,14 @@ class PortageSystem (SystemInterface): return None - def find_packages (self, key = "", pkgSet = "all", masked = False, with_version = True, only_cpv = False): - if key is None: key = "" - - is_regexp = key == "" or ("*" in key and key[0] not in ("*","=","<",">","~","!")) - - def installed(key): - if is_regexp: - if with_version: - t = self.settings.vartree.dbapi.cpv_all() - else: - t = self.settings.vartree.dbapi.cp_all() - - if key: - t = filter(lambda x: re.match(key, x, re.I), t) - - return t - else: - return self.settings.vartree.dbapi.match(key) - - def tree(key): - if is_regexp: - if with_version: - t = self.settings.porttree.dbapi.cpv_all() - else: - t = self.settings.porttree.dbapi.cp_all() - - if key: - t = filter(lambda x: re.match(key, x, re.I), t) - - elif masked: - t = self.settings.porttree.dbapi.xmatch("match-all", key) - else: - t = self.settings.porttree.dbapi.match(key) - - return t - - def all(key): - return unique_array(installed(key)+tree(key)) - - def uninstalled (key): - alist = set(all(key)) - inst = set(installed(key)) - return list(alist - inst) - - def _ws (key, crit, pkglist): - pkgs = self.__find_resolved_unresolved(pkglist, crit, only_cpv = with_version)[0] - if not with_version: - pkgs = [x.get_cp(x) for x in list] - - if is_regexp: - return filter(lambda x: re.match(key, x, re.I), pkgs) - - return pkgs - - def world (key): - with open(portage.WORLD_FILE) as f: - pkglist = f.readlines() - - return _ws(key, lambda cpv: cpv[0] != "#", pkglist) - - def system (key): - return _ws(key, lambda cpv: cpv[0] == "*", self.settings.settings.packages) - - funcmap = { - "all" : all, - "installed" : installed, - "uninstalled" : uninstalled, - "world" : world, - "system" : system, - "tree" : tree - } - + def _get_set (self, pkgSet): pkgSet = pkgSet.lower() - if pkgSet == "": pkgSet = "all" + if pkgSet == "": pkgSet = self.SET_ALL - func = funcmap[pkgSet] - - try: - t = func(key) - # catch the "ambigous package" Exception - except ValueError, e: - if isinstance(e[0], list): - t = [] - for cp in e[0]: - t += func(cp) - else: - raise - - # Make the list of packages unique - t = unique_array(t) - t.sort() - - return self.geneticize_list(t, only_cpv or not with_version) + return self.setmap[pkgSet]() - def __find_resolved_unresolved (self, list, check, only_cpv = False): - """Checks a given list and divides it into a "resolved" and an "unresolved" part. - - @param list: list of cpv's - @type list: string[] - @param check: function called to check whether an entry is ok - @type check: function(cpv) - @param only_cpv: do not return packages but cpv-strings - @type only_cpv: boolean - - @returns: the divided list: (resolved, unresolved) - @rtype: (Package[], Package[]) or (string[], string[])""" - resolved = [] - unresolved = [] - for x in list: - cpv = x.strip() - if cpv and check(cpv): - pkg = self.find_best_match(cpv, only_cpv = only_cpv) - if pkg: - resolved.append(pkg) - else: - unresolved.append(self.find_best_match(cpv, True, only_cpv = only_cpv)) - return (resolved, unresolved) + 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) def list_categories (self, name = None): categories = self.settings.settings.categories @@ -333,7 +251,7 @@ class PortageSystem (SystemInterface): new_packages.append(best) for p in packages: - inst = self.find_packages(p, "installed") + inst = self.find_packages(p, self.SET_INSTALLED) best_p = self.find_best_match(p) if best_p is None: @@ -359,24 +277,14 @@ class PortageSystem (SystemInterface): return new_packages def get_updated_packages (self): - packages = self.get_new_packages(self.find_packages(pkgSet = "installed", with_version = False)) + packages = self.get_new_packages(self.find_packages(pkgSet = self.SET_INSTALLED, with_version = False)) packages = [x for x in packages if x is not None and not x.is_installed()] return packages - def update_world (self, newuse = False, deep = False): - # read world file - world = open(portage.WORLD_FILE) - packages = [] - for line in world: - line = line.strip() - if len(line) == 0: continue # empty line - if line[0] == "#": continue # comment - packages.append(line) - world.close() - - # append system packages - packages.extend(unique_array([p.get_cp() for p in self.find_packages(pkgSet = "system")])) - + def update_world (self, sets = ("world", "system"), newuse = False, deep = False): + packages = set() + map(packages.add, itt.chain(*(self.find_packages(pkgSet = s, with_version = False) for s in sets))) + states = [(["RDEPEND", "PDEPEND"], True)] if self.with_bdeps(): states.append((["DEPEND"], True)) @@ -401,11 +309,11 @@ class PortageSystem (SystemInterface): tempDeep = False if not p.is_installed(): - oldList = self.find_packages(p.get_slot_cp(), "installed") + oldList = self.find_packages(p.get_slot_cp(), self.SET_INSTALLED) if oldList: old = oldList[0] # we should only have one package here - else it is a bug else: - oldList = self.sort_package_list(self.find_packages(p.get_cp(), "installed")) + oldList = self.sort_package_list(self.find_packages(p.get_cp(), self.SET_INSTALLED)) if not oldList: info(_("Found a not installed dependency: %s.") % p.get_cpv()) oldList = [p] diff --git a/portato/backend/portage/system_22.py b/portato/backend/portage/system_22.py index be27186..18e3b4e 100644 --- a/portato/backend/portage/system_22.py +++ b/portato/backend/portage/system_22.py @@ -20,6 +20,7 @@ from collections import defaultdict from .package_22 import PortagePackage_22 from .settings_22 import PortageSettings_22 from .system import PortageSystem +from . import sets as syssets class PortageSystem_22 (PortageSystem): @@ -30,5 +31,31 @@ class PortageSystem_22 (PortageSystem): self.use_descs = {} self.local_use_descs = defaultdict(dict) + self.setmap = { + self.SET_ALL : syssets.AllSet, + self.SET_INSTALLED : syssets.InstalledSet, + self.SET_UNINSTALLED : syssets.UninstalledSet, + self.SET_TREE : syssets.TreeSet + } + + def has_set_support (self): + return True + + def get_sets (self, description = False): + if description: + return ((name, set.description) for name, set in self.settings.setsconfig.getSets().iteritems()) + else: + return tuple(self.settings.setsconfig.getSets()) + + def _get_set (self, pkgSet): + pkgSet = pkgSet.lower() + if pkgSet == "": pkgSet = self.SET_ALL + + s = self.setmap.get(pkgSet, None) + if s is None: + return syssets.PortageSet(pkgSet) + else: + return s() + def new_package (self, cpv): return PortagePackage_22(cpv) diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py index 4b0f8df..1cb0ed1 100644 --- a/portato/backend/system_interface.py +++ b/portato/backend/system_interface.py @@ -11,6 +11,26 @@ # Written by René 'Necoro' Neumann <necoro@necoro.net> class SystemInterface (object): + + SET_ALL = "__portato_all__" + SET_TREE = "__portato_tree__" + SET_INSTALLED = "__portato_installed__" + SET_UNINSTALLED = "__portato_uninstalled__" + + def has_set_support (self): + """Signals, whether this backend supports sets. + + @rtype: boolean + """ + raise NotImplementedError + + def get_sets (self): + """Returns all supported sets in tuples consisting of name and description. + If sets aren't supported, at least "world" and "system" have to be returned. + + @rtype: iter(string, string) + """ + raise NotImplementedError def get_version (self): """Returns the version of the used backend. @@ -75,7 +95,7 @@ class SystemInterface (object): raise NotImplementedError - def find_packages (self, key, pkgSet = "all", masked = False, with_version = True, only_cpv = False): + def find_packages (self, key, pkgSet = SET_ALL, masked = False, with_version = True, only_cpv = False): """This returns a list of packages matching the key. As key, it is allowed to use basic regexps (".*") and the normal package specs. But not a combination of them. diff --git a/portato/gui/queue.py b/portato/gui/queue.py index 4bcd41a..c04d449 100644 --- a/portato/gui/queue.py +++ b/portato/gui/queue.py @@ -143,7 +143,7 @@ class EmergeQueue: try: pkg = self._get_pkg_from_cpv(cpv, unmask) if not pkg.is_installed(): - old = system.find_packages(pkg.get_slot_cp(), "installed") + old = system.find_packages(pkg.get_slot_cp(), system.SET_INSTALLED) if old: old = old[0] # assume we have only one there cmp = pkg.compare_version(old) @@ -272,7 +272,7 @@ class EmergeQueue: # get the blocks that block an installed package inst = [] for block in self.blocks[type]: - pkgs = system.find_packages(block, "installed") + pkgs = system.find_packages(block, system.SET_INSTALLED) if pkgs: inst.append((pkgs, block)) diff --git a/portato/gui/templates/PreferenceWindow.glade b/portato/gui/templates/PreferenceWindow.glade index 3dc556b..7c144e7 100644 --- a/portato/gui/templates/PreferenceWindow.glade +++ b/portato/gui/templates/PreferenceWindow.glade @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--Generated with glade3 3.4.4 on Sun Jun 8 01:45:17 2008 --> +<!--Generated with glade3 3.4.4 on Wed Jul 9 21:08:44 2008 --> <glade-interface> <widget class="GtkWindow" id="PreferenceWindow"> <property name="border_width">5</property> @@ -121,6 +121,42 @@ <property name="position">1</property> </packing> </child> + <child> + <widget class="GtkFrame" id="setFrame"> + <property name="no_show_all">True</property> + <property name="label_xalign">0</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + <child> + <widget class="GtkAlignment" id="alignment4"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="right_padding">10</property> + <child> + <widget class="GtkTreeView" id="setList"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <property name="rules_hint">True</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkLabel" id="label12"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Package sets to update</b></property> + <property name="use_markup">True</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="position">2</property> + </packing> + </child> </widget> </child> </widget> @@ -517,7 +553,7 @@ <property name="can_focus">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="has_tooltip">True</property> - <property name="tooltip_markup" translatable="yes">Update the package list with the current search results while you are typing. + <property name="tooltip_markup">Update the package list with the current search results while you are typing. <b>Note</b>: Will slow down the typing process.</property> <property name="label" translatable="yes">Search while typing</property> <property name="yalign">0.47999998927116394</property> @@ -766,7 +802,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="has_tooltip">True</property> - <property name="tooltip_markup" translatable="yes">Organize the categories in a tree. Thereby collapse categories with the same prefix: + <property name="tooltip_markup">Organize the categories in a tree. Thereby collapse categories with the same prefix: As an example: <i>app-admin</i>, <i>app-emacs</i>, and <i>app-vim</i> would be collapsed into <i><b>app</b></i> as root and <i>admin</i>, <i>emacs</i>, and <i>vim</i> as children.</property> <property name="label" translatable="yes">Collapse categories with same prefix</property> <property name="response_id">0</property> diff --git a/portato/gui/utils.py b/portato/gui/utils.py index c4f25fa..923f2fa 100644 --- a/portato/gui/utils.py +++ b/portato/gui/utils.py @@ -185,7 +185,7 @@ class Database (object): # get the lists packages = system.find_packages(category, with_version = False) - installed = system.find_packages(category, "installed", with_version = False) + installed = system.find_packages(category, system.SET_INSTALLED, with_version = False) # cycle through packages for p in packages: diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index 265d4dd..50dd366 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -1313,7 +1313,7 @@ class MainWindow (Window): if pkg.is_installed(): installed = set(pkg.get_iuse_flags()).intersection(pkg.get_installed_use_flags()) else: - inst = system.find_packages(pkg.get_slot_cp(), "installed") + inst = system.find_packages(pkg.get_slot_cp(), system.SET_INSTALLED) if inst: installed = set(inst[0].get_iuse_flags()).intersection(inst[0].get_installed_use_flags()) else: @@ -1420,7 +1420,13 @@ class MainWindow (Window): watch = gtk.gdk.Cursor(gtk.gdk.WATCH) self.window.window.set_cursor(watch) try: - updating = system.update_world(newuse = self.cfg.get_boolean("newuse"), deep = self.cfg.get_boolean("deep")) + sets = ("world", "system") # default + if system.has_set_support(): + confsets = [x.strip() for x in self.cfg.get("updatesets").split(",")] + syssets = system.get_sets() + sets = [s for s in confsets if s in syssets] + + updating = system.update_world(sets = sets, newuse = self.cfg.get_boolean("newuse"), deep = self.cfg.get_boolean("deep")) debug("updating list: %s --> length: %s", [(x.get_cpv(), y.get_cpv()) for x,y in updating], len(updating)) gobject.idle_add(cb_idle_append, updating) finally: diff --git a/portato/gui/windows/plugin.py b/portato/gui/windows/plugin.py index 392654e..a0694be 100644 --- a/portato/gui/windows/plugin.py +++ b/portato/gui/windows/plugin.py @@ -134,7 +134,7 @@ class PluginWindow (AbstractDialog): if plugin.deps: for dep in plugin.deps: - if system.find_packages(dep, pkgSet = "installed", with_version = False): + if system.find_packages(dep, pkgSet = system.SET_INSTALLED, with_version = False): self.inst.append(dep) else: self.ninst.append(dep) diff --git a/portato/gui/windows/preference.py b/portato/gui/windows/preference.py index d35666d..8aabbba 100644 --- a/portato/gui/windows/preference.py +++ b/portato/gui/windows/preference.py @@ -14,6 +14,8 @@ from __future__ import absolute_import import gtk +from ...backend import system + from .basic import AbstractDialog from ..dialogs import io_ex_dialog from ...helper import debug @@ -106,6 +108,12 @@ class PreferenceWindow (AbstractDialog): self.tree.get_widget(edit).\ set_text(self.cfg.get(val)) + # the set list + self.setList = self.tree.get_widget("setList") + if system.has_set_support(): + self.fill_setlist() + self.tree.get_widget("setFrame").show() + # the console font button self.consoleFontBtn = self.tree.get_widget("consoleFontBtn") self.consoleFontBtn.set_font_name(self.cfg.get("consolefont", section = "GUI")) @@ -144,6 +152,8 @@ class PreferenceWindow (AbstractDialog): else: self.cfg.set(val,self.tree.get_widget(edit).get_text()) + self.cfg.set("updatesets", ", ".join(sorted(name for enabled, markup, descr, name in self.setList.get_model() if enabled))) + font = self.consoleFontBtn.get_font_name() self.cfg.set("consolefont", font, section = "GUI") self.console_fn(font) @@ -162,6 +172,29 @@ class PreferenceWindow (AbstractDialog): self.catmodel_fn() + def fill_setlist (self): + store = gtk.ListStore(bool, str, str, str) + + enabled = [x.strip() for x in self.cfg.get("updatesets").split(",")] + + for set, descr in system.get_sets(description = True): + store.append([set in enabled, "<i>%s</i>" % set, descr, set]) + + tCell = gtk.CellRendererToggle() + tCell.set_property("activatable", True) + tCell.connect("toggled", self.cb_check_toggled) # emulate the normal toggle behavior ... + + sCell = gtk.CellRendererText() + + col = gtk.TreeViewColumn(_("Package Set"), tCell, active = 0) + col.pack_start(sCell) + col.add_attribute(sCell, "markup", 1) + self.setList.append_column(col) + + self.setList.append_column(gtk.TreeViewColumn(_("Description"), sCell, text = 2)) + + self.setList.set_model(store) + def cb_ok_clicked(self, button): """Saves, writes to config-file and closes the window.""" self._save() @@ -175,3 +208,9 @@ class PreferenceWindow (AbstractDialog): def cb_cancel_clicked (self, button): """Just closes - w/o saving.""" self.window.destroy() + + def cb_check_toggled (self, cell, path): + # for whatever reason we have to define normal toggle behavior explicitly + store = self.setList.get_model() + store[path][0] = not store[path][0] + return True diff --git a/portato/helper.py b/portato/helper.py index 31e25d9..145716e 100644 --- a/portato/helper.py +++ b/portato/helper.py @@ -110,7 +110,6 @@ def unique_array(s): """Stolen from portage_utils: lifted from python cookbook, credit: Tim Peters Return a list of the elements in s in arbitrary order, sans duplicates""" - n = len(s) # assume all elements are hashable, if so, it's linear try: return list(set(s)) @@ -124,6 +123,7 @@ def unique_array(s): except TypeError: pass else: + n = len(s) assert n > 0 last = t[0] lasti = i = 1 diff --git a/portato/plugin.py b/portato/plugin.py index 0119909..0bb161c 100644 --- a/portato/plugin.py +++ b/portato/plugin.py @@ -150,7 +150,7 @@ class Plugin (object): """ for d in self.deps: - if not system.find_packages(d, pkgSet="installed", with_version = False): + if not system.find_packages(d, pkgSet=system.SET_INSTALLED, with_version = False): self._unresolved_deps = True break |