From 860f59e2a4a7a8daeb9683d6938986afc694cf6d Mon Sep 17 00:00:00 2001 From: necoro <> Date: Thu, 31 May 2007 19:45:22 +0000 Subject: Some interface changes Made qt-frontend work mostly with PyQt-4.2 --- portato/backend/package.py | 21 +++++++++++++++++---- portato/backend/portage/package.py | 21 +++++++++++++-------- portato/backend/portage/system.py | 6 ++++++ portato/backend/system_interface.py | 12 ++++++++++++ portato/gui/qt/windows.py | 22 +++++++++++++++------- 5 files changed, 63 insertions(+), 19 deletions(-) diff --git a/portato/backend/package.py b/portato/backend/package.py index b32268f..72cd671 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -304,6 +304,9 @@ class Package: def get_matched_dep_packages (self, depvar): """This function looks for all dependencies which are resolved. In normal case it makes only sense for installed packages, but should work for uninstalled ones too. + @param depvar: the dependency variables (RDEPEND, PDEPEND, DEPEND) to use + @type depvar: string[] + @returns: unique list of dependencies resolved (with elements like "<=net-im/foobar-1.2.3") @rtype: string[] @@ -311,11 +314,16 @@ class Package: raise NotImplementedError - def get_dep_packages (self, depvar = ["RDEPEND", "PDEPEND", "DEPEND"]): + def get_dep_packages (self, depvar = ["RDEPEND", "PDEPEND", "DEPEND"], with_criterions = False): """Returns a cpv-list of packages on which this package depends and which have not been installed yet. This does not check the dependencies in a recursive manner. - @returns: list of cpvs on which the package depend - @rtype: string[] + @param depvar: the dependency variables (RDEPEND, PDEPEND, DEPEND) to use + @type depvar: string[] + @param with_criterions: return also the criterions + @type with_criterions: boolean + + @returns: list of cpvs on which the package depend (and if wanted also the criterions) + @rtype: string[] or (string, string)[] @raises portato.BlockedException: when a package in the dependency-list is blocked by an installed one @raises portato.PackageNotFoundException: when a package in the dependency list could not be found in the system @@ -362,7 +370,12 @@ class Package: raise NotImplementedError def compare_version(self, other): - """Compares this package's version to another's CPV; returns -1, 0, 1""" + """Compares this package's version to another's CPV; returns -1, 0, 1. + + @param other: the other package + @type other: Package + @returns: -1, 0 or 1 + @rtype: int""" raise NotImplementedError diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index 9f40137..d22d203 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -163,7 +163,7 @@ class PortagePackage (Package): return retlist - def get_dep_packages (self, depvar = ["RDEPEND", "PDEPEND", "DEPEND"]): + def get_dep_packages (self, depvar = ["RDEPEND", "PDEPEND", "DEPEND"], with_criterions = False): dep_pkgs = [] # the package list # change the useflags, because we have internally changed some, but not made them visible for portage @@ -192,6 +192,14 @@ class PortagePackage (Package): deps = deps[1] + def create_dep_pkgs_data (dep, pkg): + """Returns the data to enter into the dep_pkgs list, which is either the package cpv or a tuple + consisting of the cpv and the criterion.""" + if with_criterions: + return (pkg.get_cpv(), dep) + else: + return pkg.get_cpv() + for dep in deps: if dep[0] == '!': # blocking sth dep = dep[1:] @@ -212,13 +220,13 @@ class PortagePackage (Package): for i in range(len(list)-1,0,-1): p = list[i] if not p.is_masked(): - dep_pkgs.append(p.get_cpv()) + dep_pkgs.append(create_dep_pkgs_data(dep, p)) done = True break if not done: - dep_pkgs.append(list[-1].get_cpv()) + dep_pkgs.append(create_dep_pkgs_data(dep, list[-1])) else: - dep_pkgs.append(pkg.get_cpv()) + dep_pkgs.append(create_dep_pkgs_data(dep, pkg)) return dep_pkgs @@ -262,7 +270,4 @@ class PortagePackage (Package): return portage.pkgcmp(v1[1:],v2[1:]) def matches (self, criterion): - if portage.match_from_list(criterion, [self.get_cpv()]) == []: - return False - else: - return True + return system.cpv_matches(self.get_cpv(), criterion) diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index 27099cc..ddc4a8e 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -79,6 +79,12 @@ class PortageSystem (SystemInterface): return opts + def cpv_matches (self, cpv, criterion): + if portage.match_from_list(criterion, [self.get_cpv()]) == []: + return False + else: + return True + def find_lambda (self, name): """Returns the function needed by all the find_all_*-functions. Returns None if no name is given. diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py index 40834f9..9af0b33 100644 --- a/portato/backend/system_interface.py +++ b/portato/backend/system_interface.py @@ -21,6 +21,18 @@ class SystemInterface: @rtype: string[]""" raise NotImplementedError + + def cpv_matches (self, cpv, criterion): + """Checks whether a cpv matches a specific criterion. + + @param cpv: cpv to check + @type cpv: string + @param criterion: criterion to check against + @type criterion: string + @returns: match result + @rtype: boolean""" + + raise NotImplementedError def find_best(self, list): """Returns the best package out of a list of packages. diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py index bf7be49..58f923e 100644 --- a/portato/gui/qt/windows.py +++ b/portato/gui/qt/windows.py @@ -70,9 +70,12 @@ class Window (object): Qt.QApplication.setOverrideCursor(Qt.Qt.WaitCursor) try: - ret = func(*args, **kwargs) - finally: - Qt.QApplication.restoreOverrideCursor() + try: + ret = func(*args, **kwargs) + finally: + Qt.QApplication.restoreOverrideCursor() + except TypeError: + pass # invalid signature called return ret @@ -743,8 +746,8 @@ class MainWindow (Window): def on_prefAction_triggered (self): PreferenceWindow(self, self.cfg).exec_() - @Qt.pyqtSignature("") @Window.watch_cursor + @Qt.pyqtSignature("") def on_reloadAction_triggered (self): """Reloads the portage settings and the database.""" system.reload_settings() @@ -800,12 +803,17 @@ class MainWindow (Window): self.fill_pkg_list(self.selCatName) @Qt.pyqtSignature("") - @Window.watch_cursor def on_searchBtn_clicked (self): """Do a search.""" text = str(self.searchEdit.text()) + if text != "": - packages = system.find_all_packages(text, withVersion = False) + + @Window.watch_cursor + def get_packages(): + return system.find_all_packages(text, withVersion = False) + + packages = get_packages() if packages == []: nothing_found_dialog(self) @@ -865,8 +873,8 @@ class MainWindow (Window): self.tabWidget.setCurrentIndex(self.CONSOLE_PAGE) self.queue.unmerge(force = True) - @Qt.pyqtSignature("") @Window.watch_cursor + @Qt.pyqtSignature("") def on_updateBtn_clicked (self): if not am_i_root(): not_root_dialog(self) -- cgit v1.2.3-70-g09d2