From 3b446c965b7319ed56d69057743220c8278e0703 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Thu, 17 Apr 2008 11:50:38 +0200 Subject: Cleaned up interface --- portato/backend/system_interface.py | 131 +++--------------------------------- 1 file changed, 11 insertions(+), 120 deletions(-) (limited to 'portato/backend/system_interface.py') diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py index a523af7..3c50675 100644 --- a/portato/backend/system_interface.py +++ b/portato/backend/system_interface.py @@ -75,31 +75,20 @@ class SystemInterface (object): raise NotImplementedError - def find_packages (self, search_key, masked = False, only_cpv = False): - """This returns a list of packages which have to fit exactly. Additionally ranges like '<,>,=,~,!' et. al. are possible. + def find_packages (self, key, 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. - @param search_key: the key to look for - @type search_key: string - @param masked: if True, also look for masked packages - @type masked: boolean - @param only_cpv: do not return package but only the cpv - @type only_cpv: boolean - - @returns: list of found packages - @rtype: backend.Package[] or string[] - """ - - raise NotImplementedError - - - def find_installed_packages (self, search_key, masked = False, only_cpv = False): - """This returns a list of packages which have to fit exactly. Additionally ranges like '<,>,=,~,!' et. al. are possible. - - @param search_key: the key to look for - @type search_key: string + @param key: the key to look for + @type key: string + @param all: the package set to use + @type all: string @param masked: if True, also look for masked packages @type masked: boolean - @param only_cpv: do not return package but only the cpv + @param with_version: if True, return CPVs - else CP + @type with_version: boolean + @param only_cpv: do not return package but only the cpv. if with_version is False, this is ignored @type only_cpv: boolean @returns: list of found packages @@ -108,104 +97,6 @@ class SystemInterface (object): raise NotImplementedError - def find_system_packages (self, only_cpv = False): - """Looks for all packages saved as "system-packages". - - @param only_cpv: do not return package but only the cpv - @type only_cpv: boolean - - @returns: a tuple of (resolved_packages, unresolved_packages). - @rtype: (backend.Package[], backend.Package[]) or (string[], string[]) - """ - - raise NotImplementedError - - def find_world_packages (self, only_cpv = False): - """Looks for all packages saved in the world-file. - - @param only_cpv: do not return package but only the cpv - @type only_cpv: boolean - - @returns: a tuple of (resolved_packages, unresolved_packages). - @rtype: (backend.Package[], backend.Package[]) or (string[], string[]) - """ - - raise NotImplementedError - - def find_all_installed_packages (self, name = None, withVersion = True, only_cpv = False): - """Finds all installed packages matching a name or all if no name is specified. - - @param name: the name to look for - it is expanded to .*name.* ; if None, all packages are returned - @type name: string or None - @param withVersion: if True version-specific packages are returned; else only the cat/package-strings a delivered - @type withVersion: boolean - @param only_cpv: do not return package but only the cpv - @type only_cpv: boolean - - @returns: all packages/cp-strings found - @rtype: backend.Package[] or string[] - """ - - raise NotImplementedError - - def find_all_uninstalled_packages (self, name = None, only_cpv = False): - """Finds all uninstalled packages matching a name or all if no name is specified. - - @param name: the name to look for - it is expanded to .*name.* ; if None, all packages are returned - @type name: string or None - @param only_cpv: do not return package but only the cpv - @type only_cpv: boolean - - @returns: all packages found - @rtype: backend.Package[] or string[] - """ - - raise NotImplementedError - - def find_all_packages (self, name = None, withVersion = True, only_cpv = False): - """Finds all packages matching a name or all if no name is specified. - - @param name: the name to look for - it is expanded to .*name.* ; if None, all packages are returned - @type name: string or None - @param withVersion: if True version-specific packages are returned; else only the cat/package-strings a delivered - @type withVersion: boolean - @param only_cpv: do not return package but only the cpv - @type only_cpv: boolean - - @returns: all packages/cp-strings found - @rtype: backend.Package[] or string[] - """ - - raise NotImplementedError - - def find_all_world_packages (self, name = None, only_cpv = False): - """Finds all world packages matching a name or all if no name is specified. - - @param name: the name to look for - it is expanded to .*name.* ; if None, all packages are returned - @type name: string or None - @param only_cpv: do not return package but only the cpv - @type only_cpv: boolean - - @returns: all packages found - @rtype: backend.Package[] or string[] - """ - - raise NotImplementedError - - def find_all_system_packages (self, name = None, only_cpv = False): - """Finds all system packages matching a name or all if no name is specified. - - @param name: the name to look for - it is expanded to .*name.* ; if None, all packages are returned - @type name: string or None - @param only_cpv: do not return package but only the cpv - @type only_cpv: boolean - - @returns: all packages found - @rtype: backend.Package[] or string[] - """ - - raise NotImplementedError - def list_categories (self, name = None): """Finds all categories matching a name or all if no name is specified. -- cgit v1.2.3-70-g09d2 From f10c0e92853aef25a765925bd54608ced73cd164 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Thu, 17 Apr 2008 21:24:25 +0200 Subject: Fixed get_use_desc --- portato/backend/portage/system.py | 25 +++++++++++++++++-------- portato/backend/system_interface.py | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'portato/backend/system_interface.py') diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index 0b5124c..78afa52 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -3,14 +3,14 @@ # File: portato/backend/portage/system.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2007 René 'Necoro' Neumann +# Copyright (C) 2006-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 -from __future__ import absolute_import +from __future__ import absolute_import, with_statement import re, os, os.path import portage @@ -467,17 +467,24 @@ class PortageSystem (SystemInterface): # fill cache if needed if not self.use_descs and not self.local_use_descs: for dir in [self.settings.settings["PORTDIR"]] + self.settings.settings["PORTDIR_OVERLAY"].split(): + # read use.desc - with open(os.path.join(dir, "profiles/use.desc")) as f: + try: + f = open(os.path.join(dir, "profiles/use.desc")) for line in f: line = line.strip() if line and line[0] != '#': fields = [x.strip() for x in line.split(" - ",1)] if len(fields) == 2: self.use_descs[fields[0]] = fields[1] + except IOError: + pass + finally: + f.close() # read use.local.desc - with open(os.path.join(dir, "profiles/use.local.desc")) as f: + try: + f = open(os.path.join(dir, "profiles/use.local.desc")) for line in f: line = line.strip() if line and line[0] != '#': @@ -486,13 +493,15 @@ class PortageSystem (SystemInterface): subfields = [x.strip() for x in fields[1].split(" - ",1)] if len(subfields) == 2: self.local_use_descs[fields[0]].update([subfields]) + except IOError: + pass + finally: + f.close() # start - desc = self.use_descs.get(flag) + desc = self.use_descs.get(flag, "") if package is not None: if package in self.local_use_descs: - desc = self.local_use_descs[package].get(flag) + desc = self.local_use_descs[package].get(flag, desc) - if desc is None: return "" - return desc diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py index 3c50675..c22c857 100644 --- a/portato/backend/system_interface.py +++ b/portato/backend/system_interface.py @@ -3,7 +3,7 @@ # File: portato/backend/system_interface.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2007 René 'Necoro' Neumann +# Copyright (C) 2007-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. -- cgit v1.2.3-70-g09d2 From 406603141a35e2be08e559fc9ec090c6c968b596 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Wed, 21 May 2008 20:37:09 +0200 Subject: Fixed errors, so the app starts --- portato/backend/portage/system.py | 14 ++++++++------ portato/backend/system_interface.py | 2 +- portato/gui/utils.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'portato/backend/system_interface.py') diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index adb9799..f92e34e 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -162,21 +162,23 @@ class PortageSystem (SystemInterface): else: pkgSet = "installed" - t = self.find_packages(search_key, pkgSet = pkgSet, masked = masked, with_version = True) + t = self.find_packages(search_key, pkgSet = pkgSet, masked = masked, with_version = True, only_cpv = True) if t: return self.find_best(t) - return t + return self.geneticize_list(t, only_cpv) 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: @@ -259,7 +261,7 @@ class PortageSystem (SystemInterface): t = unique_array(t) t.sort() - return geneticize_list(t, only_cpv or not with_version) + return self.geneticize_list(t, only_cpv or not with_version) def __find_resolved_unresolved (self, list, check, only_cpv = False): """Checks a given list and divides it into a "resolved" and an "unresolved" part. @@ -337,7 +339,7 @@ class PortageSystem (SystemInterface): return new_packages def get_updated_packages (self): - packages = self.get_new_packages(self.find_packages(set = "installed", with_version = False)) + packages = self.get_new_packages(self.find_packages(pkgSet = "installed", with_version = False)) packages = [x for x in packages if x is not None and not x.is_installed()] return packages @@ -353,7 +355,7 @@ class PortageSystem (SystemInterface): world.close() # append system packages - packages.extend(unique_array([p.get_cp() for p in self.find_packages(set = "system")])) + packages.extend(unique_array([p.get_cp() for p in self.find_packages(pkgSet = "system")])) states = [(["RDEPEND"], True)] if self.with_bdeps(): diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py index c22c857..4b0f8df 100644 --- a/portato/backend/system_interface.py +++ b/portato/backend/system_interface.py @@ -75,7 +75,7 @@ class SystemInterface (object): raise NotImplementedError - def find_packages (self, key, set = "all", masked = False, with_version = True, only_cpv = False): + def find_packages (self, key, pkgSet = "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/utils.py b/portato/gui/utils.py index 7a3e8ee..59210e1 100644 --- a/portato/gui/utils.py +++ b/portato/gui/utils.py @@ -166,7 +166,7 @@ class Database (object): # get the lists packages = system.find_packages(category, with_version = False) - installed = system.find_packages(category, set = "installed", with_version = False) + installed = system.find_packages(category, "installed", with_version = False) # cycle through packages for p in packages: -- cgit v1.2.3-70-g09d2