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/gui_helper.py | |
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/gui_helper.py')
-rw-r--r-- | geneticone/gui/gui_helper.py | 44 |
1 files changed, 34 insertions, 10 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. |