summaryrefslogtreecommitdiff
path: root/portato/backend
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-06-26 22:37:56 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-06-26 22:37:56 +0200
commitc10d60d57fc5c3f0eff217f216ce4f0a0897cb55 (patch)
tree6e7fc01369f1cd9e3a53cf092b4e5a7e50023e3b /portato/backend
parent1898e03577eac27a8e27561eda952647643ec69b (diff)
downloadportato-c10d60d57fc5c3f0eff217f216ce4f0a0897cb55.tar.gz
portato-c10d60d57fc5c3f0eff217f216ce4f0a0897cb55.tar.bz2
portato-c10d60d57fc5c3f0eff217f216ce4f0a0897cb55.zip
Removed '__find_resolved_unresolved' as it is quite useless.
Also removed the "find_packages::ws" and moved the content into "world" and "system" to prepare for exchangebility.
Diffstat (limited to 'portato/backend')
-rw-r--r--portato/backend/portage/system.py78
-rw-r--r--portato/backend/system_interface.py2
2 files changed, 28 insertions, 52 deletions
diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py
index 58f687e..229bcc9 100644
--- a/portato/backend/portage/system.py
+++ b/portato/backend/portage/system.py
@@ -14,6 +14,11 @@ from __future__ import absolute_import, with_statement
import re, os, os.path
import portage
+try:
+ import portage.dep as portage_dep
+except ImportError:
+ import portage_dep
+
from collections import defaultdict
from . import VERSION
@@ -226,24 +231,30 @@ class PortageSystem (SystemInterface):
inst = set(installed(key))
return list(alist - inst)
- def _ws (key, crit, pkglist):
- pkgs = self.__find_resolved_unresolved(pkglist, crit, only_cpv = with_version)[0]
- if not with_version:
- pkgs = [x.get_cp(x) for x in list]
-
- if is_regexp:
- return filter(lambda x: re.match(key, x, re.I), pkgs)
-
- return pkgs
-
def world (key):
with open(portage.WORLD_FILE) as f:
- pkglist = f.readlines()
+ for cp in f:
+ cp = cp.strip()
+ if cp and cp[0] != "#":
+ if is_regexp:
+ if not re.match(key, cp, re.I): continue
- return _ws(key, lambda cpv: cpv[0] != "#", pkglist)
+ if not with_version:
+ yield portage_dep.dep_getkey(cp)
+
+ yield self.find_best_match(cp, only_cpv = True)
def system (key):
- return _ws(key, lambda cpv: cpv[0] == "*", self.settings.settings.packages)
+ for cp in self.settings.settings.packages:
+ if cp[0] != "*": continue
+
+ if is_regexp:
+ if not re.match(key, cp, re.I): continue
+
+ if not with_version:
+ yield portage_dep.dep_getkey(cp)
+
+ yield self.find_best_match(cp, only_cpv = True)
funcmap = {
"all" : all,
@@ -272,34 +283,9 @@ class PortageSystem (SystemInterface):
# Make the list of packages unique
t = unique_array(t)
- t.sort()
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.
-
- @param list: list of cpv's
- @type list: string[]
- @param check: function called to check whether an entry is ok
- @type check: function(cpv)
- @param only_cpv: do not return packages but cpv-strings
- @type only_cpv: boolean
-
- @returns: the divided list: (resolved, unresolved)
- @rtype: (Package[], Package[]) or (string[], string[])"""
- resolved = []
- unresolved = []
- for x in list:
- cpv = x.strip()
- if cpv and check(cpv):
- pkg = self.find_best_match(cpv, only_cpv = only_cpv)
- if pkg:
- resolved.append(pkg)
- else:
- unresolved.append(self.find_best_match(cpv, True, only_cpv = only_cpv))
- return (resolved, unresolved)
-
def list_categories (self, name = None):
categories = self.settings.settings.categories
return filter(self.find_lambda(name), categories)
@@ -357,19 +343,9 @@ class PortageSystem (SystemInterface):
return packages
def update_world (self, newuse = False, deep = False):
- # read world file
- world = open(portage.WORLD_FILE)
- packages = []
- for line in world:
- line = line.strip()
- if len(line) == 0: continue # empty line
- if line[0] == "#": continue # comment
- packages.append(line)
- world.close()
-
- # append system packages
- packages.extend(unique_array([p.get_cp() for p in self.find_packages(pkgSet = "system")]))
-
+ packages = self.find_packages(pkgSet="world", with_version = False)
+ packages.extend(self.find_packages(pkgSet = "system", with_version = False))
+
states = [(["RDEPEND", "PDEPEND"], True)]
if self.with_bdeps():
states.append((["DEPEND"], True))
diff --git a/portato/backend/system_interface.py b/portato/backend/system_interface.py
index 16f0a9c..c118f6d 100644
--- a/portato/backend/system_interface.py
+++ b/portato/backend/system_interface.py
@@ -23,7 +23,7 @@ class SystemInterface (object):
"""Returns all supported sets in tuples consisting of name and description.
If sets aren't supported, at least "world" and "system" have to be returned.
- @rtype: (string, string)[]
+ @rtype: iter(string, string)
"""
raise NotImplementedError