diff options
author | necoro <> | 2006-10-01 09:34:14 +0000 |
---|---|---|
committer | necoro <> | 2006-10-01 09:34:14 +0000 |
commit | 2d934d502bde0d3ca5c4b40b9655df18d8d36ab0 (patch) | |
tree | cb8a9d9538888e262dd2cb2b0315cc4207e46da5 /geneticone/gui | |
parent | 3b985bff8f9f76e29f6dd3e15e6ecf4d01388e2c (diff) | |
download | portato-2d934d502bde0d3ca5c4b40b9655df18d8d36ab0.tar.gz portato-2d934d502bde0d3ca5c4b40b9655df18d8d36ab0.tar.bz2 portato-2d934d502bde0d3ca5c4b40b9655df18d8d36ab0.zip |
Implemented an internal db; removed unmerge-bug
Diffstat (limited to 'geneticone/gui')
-rw-r--r-- | geneticone/gui/gui_helper.py | 44 | ||||
-rw-r--r-- | geneticone/gui/windows.py | 25 |
2 files changed, 43 insertions, 26 deletions
diff --git a/geneticone/gui/gui_helper.py b/geneticone/gui/gui_helper.py index b485bf0..0113342 100644 --- a/geneticone/gui/gui_helper.py +++ b/geneticone/gui/gui_helper.py @@ -20,10 +20,37 @@ from threading import Thread import pty import vte +class Database: + + def __init__ (self): + self.db = {} + + def populate (self, cat = None): + packages = backend.find_all_packages(name = cat, withVersion = False) + installed = backend.find_all_installed_packages(name = cat, withVersion = False) + for p in packages: + list = p.split("/") + cat = list[0] + pkg = list[1] + if p in installed: + pkg += "*" + if not cat in self.db: self.db[cat] = [] + self.db[cat].append(pkg) + + def get_cat (self, cat): + try: + return self.db[cat] + except KeyError: # cat is in category list - but not in portage + return [] + + def reload (self, cat): + del self.db[cat] + self.populate(cat+"/") + class EmergeQueue: """This class manages the emerge queue.""" - def __init__ (self, tree = None, console = None, packages = None): + def __init__ (self, tree = None, console = None, db = None): """Constructor. @param tree: Tree to append all the items to. Default: None. @@ -39,7 +66,7 @@ class EmergeQueue: self.deps = {} self.tree = tree self.console = console - self.packages = packages + self.db = db if self.tree: self.emergeIt = self.tree.append(None, ["Emerge"]) @@ -133,14 +160,11 @@ class EmergeQueue: if process: process.wait() for p in packages: - try: - cat = backend.split_package_name(p)[0] # get category - while cat[0] in ["=",">","<","!"]: - cat = cat[1:] - del self.packages[cat] - debug("Category %s marked for refreshing" % cat) - except KeyError: # not in self.packages - ignore - pass + cat = backend.split_package_name(p)[0] # get category + while cat[0] in ["=",">","<","!"]: + cat = cat[1:] + self.db.reload(cat) + debug("Category %s refreshed" % cat) def _emerge (self, options, packages, it): """Calls emerge and updates the terminal. diff --git a/geneticone/gui/windows.py b/geneticone/gui/windows.py index 1cb39a1..4259848 100644 --- a/geneticone/gui/windows.py +++ b/geneticone/gui/windows.py @@ -244,7 +244,7 @@ class PackageWindow: not_root_dialog() else: try: - self.queue.append(self.actual_package().get_cpv(), False) + self.queue.append(self.actual_package().get_cpv(), unmerge = False) except backend.PackageNotFoundException, e: masked_dialog(e[0]) self.window.destroy() @@ -256,7 +256,7 @@ class PackageWindow: not_root_dialog() else: try: - self.queue.append(self.actual_package().get_cpv(), False) + self.queue.append(self.actual_package().get_cpv(), unmerge = True) except backend.PackageNotFoundException, e: masked_dialog(e[0]) @@ -360,6 +360,10 @@ class MainWindow: self.window.set_geometry_hints (self.window, min_width = 600, min_height = 800, max_height = gtk.gdk.screen_height(), max_width = gtk.gdk.screen_width()) self.window.set_resizable(True) + # package db + self.db = Database() + self.db.populate() + # main vb vb = gtk.VBox(False, 1) self.window.add(vb) @@ -459,7 +463,7 @@ class MainWindow: self.window.show_all() # set emerge queue - self.queue = EmergeQueue(console=term, tree = emergeStore, packages = self.packages) + self.queue = EmergeQueue(console=term, tree = emergeStore, db = self.db) def cb_delete (self, widget, data = None): """Returns false -> window is deleted.""" @@ -543,16 +547,7 @@ class MainWindow: # calculate packages if name: - if name not in self.packages and not force: # only calc packages if not already done - self.packages[name] = [] - list = backend.find_all_packages(name = name+"/", withVersion = False) - installed = backend.find_all_installed_packages(name = name+"/", withVersion=False) - for p in list: - if p in installed: - p += "*" # append a '*' if the package is installed - self.packages[name].append(p.split("/")[1]) - - for p in self.packages[name]: + for p in self.db.get_cat(name): store.append([p]) # sort alphabetically @@ -607,15 +602,13 @@ class MainWindow: def cb_search_clicked (self, button, data = None): """Do a search.""" if self.searchEntry.get_text() != "": - packages = backend.find_all_packages(self.searchEntry.get_text()) + packages = backend.find_all_packages(self.searchEntry.get_text(), withVersion = False) if packages == []: dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Package not found!") dialog.run() dialog.destroy() else: - packages = unique_array([p.get_cp() for p in packages]) - if len(packages) == 1: self.jump_to(packages[0]) else: |