From 46c5530abed392a2d7d91da165cffca99938f906 Mon Sep 17 00:00:00 2001 From: necoro <> Date: Mon, 2 Oct 2006 16:24:09 +0000 Subject: Corrected comments, structure, bad algorithms etc --- geneticone/gui/gui_helper.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'geneticone/gui/gui_helper.py') diff --git a/geneticone/gui/gui_helper.py b/geneticone/gui/gui_helper.py index 0113342..acbccd3 100644 --- a/geneticone/gui/gui_helper.py +++ b/geneticone/gui/gui_helper.py @@ -21,13 +21,18 @@ import pty import vte class Database: + """An internal database which holds a simple dictionary cat -> [package_list].""" def __init__ (self): + """Constructor.""" 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) + def populate (self, category = None): + """Populates the database. + @param category: An optional category - so only packages of this category are inserted. + @type category: string""" + packages = backend.find_all_packages(name = category, withVersion = False) + installed = backend.find_all_installed_packages(name = category, withVersion = False) for p in packages: list = p.split("/") cat = list[0] @@ -37,13 +42,25 @@ class Database: if not cat in self.db: self.db[cat] = [] self.db[cat].append(pkg) + for key in self.db: + self.db[key].sort(cmp=cmp, key=str.lower) + def get_cat (self, cat): + """Returns the packages in the category. + @param cat: category to return the packages from + @type cat: string + @return: list of packages or [] + @rtype: list of strings""" try: return self.db[cat] except KeyError: # cat is in category list - but not in portage return [] def reload (self, cat): + """Reloads the given category. + @param cat: category + @type cat: string""" + del self.db[cat] self.populate(cat+"/") @@ -57,8 +74,8 @@ class EmergeQueue: @type tree: gtk.TreeStore @param console: Output is shown here. Default: None @type console: vte.Terminal - @param packages: The list of packages sorted by categories. We will delete the appropriate category if we updated sth. Default: None - @type packages: dictionary: {category: list_of_packages}.""" + @param db: A database instance. + @type db: Database""" self.mergequeue = [] self.unmergequeue = [] @@ -82,7 +99,7 @@ class EmergeQueue: @param cpv: The package to append. @type cpv: string (cat/pkg-ver) - @raise geneticone.BlockedException: When occured during dependency-calculation.""" + @raise geneticone.backend.BlockedException: When occured during dependency-calculation.""" # get dependencies if cpv in self.deps: @@ -117,7 +134,8 @@ class EmergeQueue: @param unmerge: Set to True if you want to unmerge this package - else False. Default: False @type unmerge: boolean @param update: Set to True if a package is going to be updated (e.g. if the use-flags changed). Default: False - @type update: boolean""" + @type update: boolean + @raises geneticone.backend.PackageNotFoundException: if trying to add a package which does not exist""" if not unmerge: try: @@ -151,7 +169,7 @@ class EmergeQueue: self.tree.append(self.unmergeIt, [cpv]) def _update_packages(self, packages, process = None): - """This updates the packages-list. It simply removes all affected categories so they have to be rebuilt. + """This updates the packages-list. It simply makes the db to rebuild the specific category. @param packages: The packages which we emerged. @type packages: list of cpvs -- cgit v1.2.3-70-g09d2 ass='deletions'>-1/+1 2010-04-17Updated italian translation. Thx to PonsiRené 'Necoro' Neumann1-314/+369 2010-04-16Fix gtk deprecation warningRené 'Necoro' Neumann1-1/+1 2010-04-16TypoRené 'Necoro' Neumann2-3/+3 2010-04-16Do not allow portage's sqlite backend for the moment ... bug #564292René 'Necoro' Neumann2-16/+25 2010-04-15Better sorting of the database types in the preferences.René 'Necoro' Neumann2-6/+6 Now they are displayed from best to worst. 2010-04-15Add notify-python dependency for the version checkerRené 'Necoro' Neumann1-1/+1 2010-04-15Make the database type choice an info messageRené 'Necoro' Neumann2-7/+13 2010-04-15Renamed es_ES to esRené 'Necoro' Neumann1-0/+0 2010-04-15Fixed dependancy of the new_version plugin from "dev-util/git" to ↵Clement Bourgeois1-1/+1 "dev-vcs/git" to follow new Gentoo portage tree modifications 2010-04-14Make some useless info messages being debug statementsRené 'Necoro' Neumann2-34/+17 2010-04-14Improve the C modulesRené 'Necoro' Neumann3-37/+52 2010-04-14Small modifications made to the French translation (typos, grammar).Clement Bourgeois1-69/+69 2010-04-14Fixed the unicode support and stuff ... and also made eix faster :)René 'Necoro' Neumann1-20/+22 2010-04-14Disable debug messages by defaultRené 'Necoro' Neumann1-1/+1 2010-04-13Better eix error inheritance and handlingRené 'Necoro' Neumann1-2/+9 2010-04-13Fix the handling of FilterSets. Fixes bug #558887.René 'Necoro' Neumann2-56/+64 Now FilterSets are a subclass of InstalledSet. And return only these packages, which are installed ... but then all of them. 2010-04-12Updated newsRené 'Necoro' Neumann1-0/+1 2010-04-13Added my name to translators list.Clement Bourgeois1-0/+1