From adb8acd0b90992a8281494c76d30a529bde45fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 21 May 2008 20:19:41 +0200 Subject: Ported package --- portato/backend/portage/package.py | 39 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'portato/backend/portage/package.py') diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index 37fa230..0452641 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -89,7 +89,7 @@ class PortagePackage (Package): return self._settings.vartree.dbapi.cpv_exists(self._cpv) def is_in_overlay(self): - dir,ovl = self._settings.porttree.dbapi.findname2(self._cpv) + ovl = self.get_overlay_path() return ovl != self._settings.settings["PORTDIR"] and str(ovl) != "0" def get_overlay_path (self): @@ -100,23 +100,17 @@ class PortagePackage (Package): return (self._status != None) def is_missing_keyword(self): - if self._status and "missing keyword" in self._status: - return True - return False + return self._status and "missing keyword" in self._status - def is_testing(self, use_keywords = False): + def is_testing(self, use_keywords = True): testArch = "~" + self.get_global_settings("ARCH") if not use_keywords: # keywords are NOT taken into account - if testArch in self.get_package_settings("KEYWORDS").split(): - return True - return False + return testArch in self.get_package_settings("KEYWORDS").split() else: # keywords are taken into account status = flags.new_testing_status(self.get_cpv()) if status is None: # we haven't changed it in any way - if self._status and testArch+" keyword" in self._status: - return True - return False + return self._status and testArch+" keyword" in self._status else: return status @@ -130,15 +124,13 @@ class PortagePackage (Package): else: error(_("BUG in flags.new_masking_status. It returns \'%s\'"), status) else: # we have not touched the status - if self._status and ("profile" in self._status or "package.mask" in self._status): - return True - return False + return self._status and ("profile" in self._status or "package.mask" in self._status) + else: # we want the original portage value XXX: bug if masked by user AND by system # get the normal masked ones if self._status and ("profile" in self._status or "package.mask" in self._status): - 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 + return flags.is_locally_masked(self, changes = False) # assume that if it is locally masked, it is not masked by the system else: # more difficult: get the ones we unmasked, but are masked by the system try: masked = self._settings.settings.pmaskdict[self.get_cp()] @@ -147,10 +139,7 @@ class PortagePackage (Package): 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 not flags.is_locally_masked(self, changes = False) # assume that if it is locally masked, it is not masked by the system return False @@ -158,7 +147,7 @@ class PortagePackage (Package): reason = portage.getmaskingreason(self.get_cpv(), settings = self._settings.settings) if reason: - return reason[:-1] # strip of last \n + return reason.strip() else: return reason @@ -234,9 +223,9 @@ class PortagePackage (Package): if dep[0] == '!': # blocking sth dep = dep[1:] if dep != self.get_cp(): # not cpv, because a version might explicitly block another one - blocked = system.find_installed_packages(dep) + blocked = system.find_packages(dep, "installed", only_cpv = True) if blocked != []: - raise BlockedException, (self.get_cpv(), blocked[0].get_cpv()) + raise BlockedException, (self.get_cpv(), blocked[0]) continue # finished with the blocking one -> next pkg = system.find_best_match(dep) @@ -246,10 +235,8 @@ class PortagePackage (Package): raise PackageNotFoundException, dep list = system.sort_package_list(list) - list.reverse() done = False - for i in range(len(list)): - p = list[i] + for p in reversed(list): if not p.is_masked(): dep_pkgs.append(create_dep_pkgs_data(dep, p)) done = True -- cgit v1.2.3