summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
Diffstat (limited to 'portato')
-rw-r--r--portato/backend/catapult/package.py63
-rw-r--r--portato/backend/catapult/system.py32
-rw-r--r--portato/backend/flags.py3
-rw-r--r--portato/backend/package.py47
-rw-r--r--portato/backend/portage/package.py19
5 files changed, 108 insertions, 56 deletions
diff --git a/portato/backend/catapult/package.py b/portato/backend/catapult/package.py
index ffc249b..e42ac6a 100644
--- a/portato/backend/catapult/package.py
+++ b/portato/backend/catapult/package.py
@@ -3,7 +3,7 @@
# File: portato/backend/catapult/package.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.
@@ -29,6 +29,19 @@ class CatapultPackage(Package):
dbus_object = bus.get_object("org.gentoo.catapult.portage", "/org/gentoo/catapult/Package", follow_name_owner_changes = True)
proxy = dbus.Interface(dbus_object, "org.gentoo.catapult.Package")
+ def _new_flags (self):
+ flags = self.get_new_use_flags()
+
+ nflags = []
+
+ for flag in flags:
+ if flag[0] == "~":
+ nflags.append(flag[1:], True)
+ else:
+ nflags.append(flag, False)
+
+ return nflags
+
def use_expanded (self, flag, suggest = None):
if not suggest:
suggest = ""
@@ -80,29 +93,17 @@ class CatapultPackage(Package):
if self.proxy.is_masked(self.get_cpv()):
if not flags.is_locally_masked(self, changes = False): # assume that if it is locally masked, it is not masked by the system
return True
-# else: # more difficult: get the ones we unmasked, but are masked by the system
-# try:
-# masked = self._settings.settings.pmaskdict[self.get_cp()]
-# except KeyError: # key error: not masked
-# return False
-#
-# for cpv in masked:
-# if self.matches(cpv):
-# if not flags.is_locally_masked(self, changes = False): # assume that if it is locally masked, it is not masked by the system
-# return True
-# else:
-# return False
return False
def get_masking_reason (self):
return str(self.proxy.get_masking_reason(self.get_cpv()))
- def get_iuse_flags (self, installed = False):
- return [str(x) for x in self.proxy.get_iuse_flags(self.get_cpv(), installed)]
+ def get_iuse_flags (self, installed = False, removeForced = True):
+ return [str(x) for x in self.proxy.get_iuse_flags(self.get_cpv(), installed, removeForced)]
def get_matched_dep_packages (self, depvar):
- return [str(x) for x in self.proxy.get_matched_dep_packages(self.get_cpv(), self.get_new_use_flags())]
+ return [str(x) for x in self.proxy.get_matched_dep_packages(self.get_cpv(), self._new_flags())]
def get_dep_packages (self, depvar = ["RDEPEND", "PDEPEND", "DEPEND"], with_criterions = False):
pkgs = self.proxy.get_dep_packages(self.get_cpv(), depvar, self.get_new_use_flags())
@@ -112,8 +113,8 @@ class CatapultPackage(Package):
else:
return [(str(x),str(y)) for x,y in pkgs]
- def get_global_settings(self, key):
- return str(self.proxy.get_global_settings(self.get_cpv(), key))
+ def get_global_settings(self, key, installed = True):
+ return str(self.proxy.get_global_settings(self.get_cpv(), key, installed))
def get_ebuild_path(self):
return str(self.proxy.get_ebuild_path(self.get_cpv()))
@@ -121,11 +122,33 @@ class CatapultPackage(Package):
def get_package_settings(self, var, tree = True):
return str(self.proxy.get_package_settings(self.get_cpv(), var, tree))
- def get_use_flags(self):
- return " ".join(self.proxy.get_use_flags(self.get_cpv()))
+ def get_installed_use_flags(self):
+ return self.proxy.get_installed_use_flags(self.get_cpv())
+
+ def get_actual_use_flags(self):
+ return self.proxy.get_actual_use_flags(self.get_cpv(), self._new_flags())
def compare_version(self, other):
return self.proxy.compare_version(self.get_cpv(), other.get_cpv())
def matches (self, criterion):
return self.proxy.matches(self.get_cpv(), criterion)
+
+ def get_files (self):
+ return self.proxy.get_files(self.get_cpv())
+
+ def get_dependencies (self):
+ from ...dependency import DependencyTree
+ d = DependencyTree()
+ d.add("Dependency calculation not supported for Catapult Backend")
+ return d
+
+ def get_name(self):
+ return str(self.proxy.get_name(self.get_cpv()))
+
+ def get_version(self):
+ return str(self.proxy.get_version(self.get_cpv()))
+
+ def get_category(self):
+ return str(self.proxy.get_category(self.get_cpv()))
+
diff --git a/portato/backend/catapult/system.py b/portato/backend/catapult/system.py
index da54d07..eecf122 100644
--- a/portato/backend/catapult/system.py
+++ b/portato/backend/catapult/system.py
@@ -3,7 +3,7 @@
# File: portato/backend/catapult/system.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006-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.
@@ -49,7 +49,11 @@ class CatapultSystem (SystemInterface):
def split_cpv (self, cpv):
- return [str(x) for x in self.proxy.split_cpv(cpv)]
+ split = self.proxy.split_cpv(cpv)
+ if all(split):
+ return map(str, split)
+ else:
+ return None
def cpv_matches (self, cpv, criterion):
return CatapultPackage(cpv).matches(criterion)
@@ -63,9 +67,12 @@ class CatapultSystem (SystemInterface):
def find_best_match (self, search_key, masked = False, only_installed = False, only_cpv = False):
p = self.proxy.find_best_match(search_key, masked, only_installed)
- if p and not only_cpv:
- return CatapultPackage(p)
- return str(p)
+ if p :
+ if not only_cpv:
+ return CatapultPackage(p)
+ else:
+ return str(p)
+ return None
def find_packages (self, search_key, masked = False, only_cpv = False):
return self.geneticize_list(self.proxy.find_packages(search_key, "all", masked, True), only_cpv)
@@ -156,7 +163,20 @@ class CatapultSystem (SystemInterface):
# return [(CatapultPackage(x), CatapultPackage(y)) for x,y in self.proxy.update_world(newuse, deep, {}, timeout = 300)]
def get_updated_packages (self):
- return self.geneticize_list(self.proxy.get_updated_packages())
+ ret = []
+ e = Event()
+
+ def wait (list):
+ ret.extend([CatapultPackage(x) for x in list])
+ e.set()
+
+ def error (ex):
+ e.set()
+ raise ex
+
+ self.proxy.get_updated_packages(reply_handler = wait, error_handler = error, timeout = 300)
+ e.wait()
+ return ret
def get_use_desc (self, flag, package = None):
if not package:
diff --git a/portato/backend/flags.py b/portato/backend/flags.py
index 61d27aa..163a4f7 100644
--- a/portato/backend/flags.py
+++ b/portato/backend/flags.py
@@ -160,9 +160,8 @@ def generate_path (cpv, exp):
@returns: rendered path
@rtype string"""
- cat, pkg, ver, rev = system.split_cpv(cpv)
-
if exp.find("$(") != -1:
+ cat, pkg, ver, rev = system.split_cpv(cpv)
exp = exp.replace("$(cat)",cat).\
replace("$(pkg)",pkg).\
replace("$(cat-1)",cat.split("-")[0]).\
diff --git a/portato/backend/package.py b/portato/backend/package.py
index f75360d..ab3f82a 100644
--- a/portato/backend/package.py
+++ b/portato/backend/package.py
@@ -3,7 +3,7 @@
# File: portato/backend/package.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.
@@ -25,10 +25,6 @@ class Package (_Package):
@type cpv: string (cat/pkg-ver)"""
self._cpv = cpv
- self._scpv = system.split_cpv(self._cpv)
-
- if not self._scpv:
- raise ValueError("invalid cpv: %s" % cpv)
#
# implemented
@@ -159,13 +155,29 @@ class Package (_Package):
return ("%s:%s" % (self.get_cp(), self.get_package_settings("SLOT")))
+ def get_package_path(self):
+ """Returns the path to where the ChangeLog, Manifest, .ebuild files reside.
+
+ @returns: path to the package files
+ @rtype: string"""
+
+ p = self.get_ebuild_path()
+ sp = p.split("/")
+ if len(sp):
+ import string
+ return string.join(sp[:-1],"/")
+
+ #
+ # Not implemented
+ #
+
def get_name(self):
"""Returns base name of package, no category nor version.
@returns: base-name
@rtype: string"""
- return self._scpv[1]
+ raise NotImplementedError
def get_version(self):
"""Returns version of package, with (optional) revision number.
@@ -173,10 +185,7 @@ class Package (_Package):
@returns: version-rev
@rtype: string"""
- v = self._scpv[2]
- if self._scpv[3] != "r0":
- v += "-" + self._scpv[3]
- return v
+ raise NotImplementedError
def get_category(self):
"""Returns category of package.
@@ -184,24 +193,8 @@ class Package (_Package):
@returns: category
@rtype: string"""
- return self._scpv[0]
-
- def get_package_path(self):
- """Returns the path to where the ChangeLog, Manifest, .ebuild files reside.
-
- @returns: path to the package files
- @rtype: string"""
-
- p = self.get_ebuild_path()
- sp = p.split("/")
- if len(sp):
- import string
- return string.join(sp[:-1],"/")
+ raise NotImplementedError
- #
- # Not implemented
- #
-
def is_installed(self):
"""Returns true if this package is installed (merged).
@rtype: boolean"""
diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py
index e54d1cd..16f00a4 100644
--- a/portato/backend/portage/package.py
+++ b/portato/backend/portage/package.py
@@ -3,7 +3,7 @@
# File: portato/backend/portage/package.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.
@@ -34,6 +34,11 @@ class PortagePackage (Package):
@type cpv: string (cat/pkg-ver)"""
Package.__init__(self, cpv)
+ self._scpv = system.split_cpv(self._cpv)
+
+ if not self._scpv:
+ raise ValueError("invalid cpv: %s" % cpv)
+
self._settings = system.settings
self._settingslock = system.settings.settingslock
self._settings_installed = None
@@ -69,6 +74,18 @@ class PortagePackage (Package):
dbapi = self._settings.porttree.dbapi
self._settings.settings.setcpv(self.get_cpv(), mydb = dbapi)
+
+ def get_name(self):
+ return self._scpv[1]
+
+ def get_version(self):
+ v = self._scpv[2]
+ if self._scpv[3] != "r0":
+ v += "-" + self._scpv[3]
+ return v
+
+ def get_category(self):
+ return self._scpv[0]
def is_installed(self):
return self._settings.vartree.dbapi.cpv_exists(self._cpv)