summaryrefslogtreecommitdiff
path: root/portato/backend/catapult
diff options
context:
space:
mode:
Diffstat (limited to 'portato/backend/catapult')
-rw-r--r--portato/backend/catapult/__init__.py16
-rw-r--r--portato/backend/catapult/package.py132
-rw-r--r--portato/backend/catapult/system.py174
3 files changed, 322 insertions, 0 deletions
diff --git a/portato/backend/catapult/__init__.py b/portato/backend/catapult/__init__.py
new file mode 100644
index 0000000..47fc042
--- /dev/null
+++ b/portato/backend/catapult/__init__.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/backend/catapult/__init__.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 2007 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 <necoro@necoro.net>
+
+from __future__ import absolute_import
+
+from .system import CatapultSystem
+from .package import CatapultPackage
diff --git a/portato/backend/catapult/package.py b/portato/backend/catapult/package.py
new file mode 100644
index 0000000..a756f33
--- /dev/null
+++ b/portato/backend/catapult/package.py
@@ -0,0 +1,132 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/backend/catapult/package.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 2007 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 <necoro@necoro.net>
+
+from __future__ import absolute_import, with_statement
+
+from ..package import Package
+from .. import flags
+from .. import system
+from ..exceptions import BlockedException, PackageNotFoundException
+from ...helper import debug, unique_array
+
+import dbus
+
+import os.path
+from gettext import lgettext as _
+
+class CatapultPackage(Package):
+
+ def __init__ (self, cpv):
+ Package.__init__(self, cpv)
+
+ self.bus = dbus.SessionBus()
+ # get the system
+ po = self.bus.get_object("org.gentoo.catapult.portage", "/org/gentoo/catapult/Package")
+ self.proxy = dbus.Interface(po, "org.gentoo.catapult.Package")
+
+ def use_expanded (self, flag, suggest = None):
+ if not suggest:
+ suggest = ""
+ return self.proxy.use_expanded(self.get_cpv(), flag, suggest)
+
+ def get_cp (self):
+ return self.proxy.get_cp(self.get_cpv())
+
+ def get_slot_cp (self):
+ return self.proxy.get_slot_cp(self.get_cpv())
+
+ def get_package_path(self):
+ return self.proxy.get_package_path(self.get_cpv())
+
+ def is_installed(self):
+ return self.proxy.is_installed(self.get_cpv())
+
+ def is_overlay(self):
+ return self.proxy.is_overlay(self.get_cpv())
+
+ def get_overlay_path(self):
+ return self.proxy.is_overlay_path(self.get_cpv())
+
+ def is_in_system (self):
+ return self.proxy.is_in_system(self.get_cpv())
+
+ def is_missing_keyword(self):
+ return self.proxy.is_missing_keyword(self.get_cpv())
+
+ def is_testing(self, use_keywords = False):
+ if not use_keywords:
+ return self.proxy.is_testing(self.get_cpv(), False)
+ else:
+ status = flags.new_testing_status(self.get_cpv())
+ if status is None:
+ return self.proxy.is_testing(self.get_cpv(), True)
+ else:
+ return status
+
+ def is_masked (self, use_changed = True):
+ if use_changed:
+ status = flags.new_masking_status(self.get_cpv())
+ if status != None: # we have locally changed it
+ if status == "masked": return True
+ elif status == "unmasked": return False
+ else:
+ error(_("BUG in flags.new_masking_status. It returns \'%s\'"), status)
+ else: # we have not touched the status
+ return self.proxy.is_masked(self.get_cpv())
+ else: # we want the original portage value XXX: bug if masked by user AND by system
+ 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 self.proxy.get_masking_reason(self.get_cpv())
+
+ def get_iuse_flags (self, installed = False):
+ return self.proxy.get_iuse_flags(self.get_cpv(), installed)
+
+ def get_matched_dep_packages (self, depvar):
+ return self.proxy.get_matched_dep_packages(self.get_cpv(), self.get_new_use_flags())
+
+ def get_dep_packages (self, depvar = ["RDEPEND", "PDEPEND", "DEPEND"], with_criterions = False):
+ return self.proxy.get_dep_packages(self.get_cpv(), depvar, self.get_new_use_flags(), with_criterions)
+
+ def get_global_settings(self, key):
+ return self.proxy.get_global_settings(self.get_cpv(), key)
+
+ def get_ebuild_path(self):
+ return self.proxy.get_ebuild_path(self.get_cpv())
+
+ def get_package_settings(self, var, tree = True):
+ return 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 compare_version(self, other):
+ return self.proxy.compare_version(self.get_cpv(), other)
+
+ def matches (self, criterion):
+ return self.proxy.matches(self.get_cpv(), criterion)
diff --git a/portato/backend/catapult/system.py b/portato/backend/catapult/system.py
new file mode 100644
index 0000000..ba73ef6
--- /dev/null
+++ b/portato/backend/catapult/system.py
@@ -0,0 +1,174 @@
+# -*- coding: utf-8 -*-
+#
+# 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
+# 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 <necoro@necoro.net>
+
+from __future__ import absolute_import
+
+import re, os
+from gettext import lgettext as _
+import dbus
+
+from .package import CatapultPackage
+from ..system_interface import SystemInterface
+from ...helper import debug, info, warning, unique_array
+
+class CatapultSystem (SystemInterface):
+
+ def __init__ (self):
+ SystemInterface.__init__(self)
+
+ self.bus = dbus.SessionBus()
+ # get the system
+ so = self.bus.get_object("org.gentoo.catapult.portage", "/org/gentoo/catapult/System")
+ self.proxy = dbus.Interface(so, "org.gentoo.catapult.System")
+
+ def geneticize_list (self, list_of_packages, only_cpv = False):
+ """Convertes a list of cpv's into L{backend.Package}s.
+
+ @param list_of_packages: the list of packages
+ @type list_of_packages: string[]
+ @param only_cpv: do nothing - return the passed list
+ @type only_cpv: boolean
+ @returns: converted list
+ @rtype: PortagePackage[]
+ """
+
+ if not only_cpv:
+ return [CatapultPackage(x) for x in list_of_packages]
+ else:
+ return list_of_packages
+
+
+ def split_cpv (self, cpv):
+ return self.proxy.split_cpv(cpv)
+
+ def cpv_matches (self, cpv, criterion):
+ return self.proxy.cpv_matches(cpv, criterion)
+
+ def find_best(self, list, only_cpv = False):
+ if only_cpv:
+ return self.proxy.find_best(list)
+ else:
+ return CatapultPackage(self.proxy.find_best(list))
+
+ def find_best_match (self, search_key, only_installed = False, only_cpv = False):
+ p = self.proxy.find_best_match(search_key, only_installed)
+
+ if p and not only_cpv:
+ return CatapultPackage(p)
+ return p
+
+ def find_packages (self, search_key, masked = False, only_cpv = False):
+ return self.geneticize_list(self.proxy.find_packages(search_key, masked), only_cpv)
+
+ def find_installed_packages (self, search_key, masked = False, only_cpv = False):
+ return self.geneticize_list(self.proxy.find_installed_packages(search_key, masked), only_cpv)
+
+ def find_system_packages (self, only_cpv = False):
+
+ result = self.proxy.find_system_packages()
+ if only_cpv:
+ return result
+ else:
+ return tuple(map(self.geneticize_list, result))
+
+ def find_world_packages (self, only_cpv = False):
+ result = self.proxy.find_world_packages()
+ if only_cpv:
+ return result
+ else:
+ return tuple(map(self.geneticize_list, result))
+
+ def find_all_installed_packages (self, name = None, withVersion = True, only_cpv = False):
+ if not name:
+ name = ""
+ return self.geneticize_list(self.proxy.find_all_installed_packages(name, withVersion), (not withVersion) or only_cpv)
+
+ def find_all_uninstalled_packages (self, name = None, only_cpv = False):
+ if not name:
+ name = ""
+ return self.geneticize_list(self.proxy.find_all_uninstalled_packages(name), only_cpv)
+
+ def find_all_packages (self, name = None, withVersion = True, only_cpv = False):
+ if not name:
+ name = ""
+ return self.geneticize_list(self.proxy.find_all_packages(name, withVersion), (not withVersion) or only_cpv)
+
+ def find_all_world_packages (self, name = None, only_cpv = False):
+ if not name:
+ name = ""
+ return self.geneticize_list(self.proxy.find_all_world_packages(name), only_cpv)
+
+ def find_all_system_packages (self, name = None, only_cpv = False):
+ if not name:
+ name = ""
+ return self.geneticize_list(self.proxy.find_all_system_packages(name), only_cpv)
+
+ def list_categories (self, name = None):
+ if not name:
+ name = ""
+ return self.proxy.list_categories(name)
+
+ def sort_package_list(self, pkglist):
+ return self.geneticize_list(self.proxy.sort_package_list([x.get_cpv() for x in pkglist]))
+
+ def reload_settings (self):
+ return self.proxy.reload_settings()
+
+ def update_world (self, newuse = False, deep = False):
+ return [(CatapultPackage(x), CatapultPackage(y)) for x,y in self.proxy.update_world(newuse, deep, {})]
+
+ def get_updated_packages (self):
+ return self.geneticize_list(self.proxy.get_updated_packages())
+
+ def get_use_desc (self, flag, package = None):
+ if not package:
+ package = ""
+ return self.proxy.get_use_desc(flag, package)
+
+ def get_global_settings(self, key):
+ return self.proxy.get_global_settings(key)
+
+ def new_package (self, cpv):
+ return CatapultPackage(cpv)
+
+ def get_config_path (self):
+ return self.proxy.get_config_path()
+
+ def get_world_file_path (self):
+ return self.proxy.get_world_file_path()
+
+ def get_sync_command (self):
+ return self.proxy.get_sync_command()
+
+ def get_merge_command (self):
+ return self.proxy.get_merge_command()
+
+ def get_oneshot_option (self):
+ return self.proxy.get_oneshot_option()
+
+ def get_newuse_option (self):
+ return self.proxy.get_newuse_option()
+
+ def get_deep_option (self):
+ return self.proxy.get_deep_option()
+
+ def get_update_option (self):
+ return self.proxy.get_update_option()
+
+ def get_pretend_option (self):
+ return self.proxy.get_pretend_option()
+
+ def get_unmerge_option (self):
+ return self.proxy.get_unmerge_option()
+
+ def get_environment (self):
+ return self.proxy.get_environment()