From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 412BA13800E for ; Mon, 30 Jul 2012 08:54:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 46BF0E0662; Mon, 30 Jul 2012 08:52:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 168FEE0662 for ; Mon, 30 Jul 2012 08:52:43 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 732CF1B4016 for ; Mon, 30 Jul 2012 08:52:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 21143E5444 for ; Mon, 30 Jul 2012 08:52:41 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1342716736.2c8f26987ba0e1fe111b45cd2d9566abb69372b9.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/packageinfo.py X-VCS-Directories: roverlay/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 2c8f26987ba0e1fe111b45cd2d9566abb69372b9 X-VCS-Branch: master Date: Mon, 30 Jul 2012 08:52:41 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 19f1f392-2d96-4cae-8a99-91665a435682 X-Archives-Hash: 9d1ab016bef78c0bfb921042ffb62cf8 commit: 2c8f26987ba0e1fe111b45cd2d9566abb69372b9 Author: André Erdmann mailerd de> AuthorDate: Thu Jul 19 16:52:16 2012 +0000 Commit: André Erdmann mailerd de> CommitDate: Thu Jul 19 16:52:16 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=2c8f2698 packageinfo: compare_version, has_key --- roverlay/packageinfo.py | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-) diff --git a/roverlay/packageinfo.py b/roverlay/packageinfo.py index a2910c5..f9d26d1 100644 --- a/roverlay/packageinfo.py +++ b/roverlay/packageinfo.py @@ -114,6 +114,38 @@ class PackageInfo ( object ): return True # --- end of _writelock_acquire (...) --- + def has_key ( self, *keys ): + for k in keys: + if k not in self._info: + # try harder - use get() with fallback value to see if value + # can be calculated + if self.get ( k, do_fallback=True ) is None: + return False + return True + # --- end of has_key (...) --- + + has = has_key + + def compare_version ( self, other_package ): + """Compares the version of two PackageInfo objects. + Returns 1 if self's version is higher, -1 if lower and 0 if equal. + + arguments: + * other_package -- + """ + if other_package is None: return 1 + + my_ver = self.get ( 'version', fallback_value=0 ) + other_ver = other_package.get ( 'version', fallback_value=0 ) + + if my_ver > other_ver: + return 1 + elif my_ver == other_ver: + return 0 + else: + return -1 + # --- end of compare_version (...) --- + def get ( self, key, fallback_value=None, do_fallback=False ): """Returns the value specified by key. The value is either calculated or taken from dict self._info. @@ -172,7 +204,7 @@ class PackageInfo ( object ): # fallback - if do_fallback: + if do_fallback or fallback_value is not None: return fallback_value elif key_low in self.__class__.ALWAYS_FALLBACK: From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.77) (envelope-from ) id 1Srtz0-0004VD-OK for garchives@archives.gentoo.org; Thu, 19 Jul 2012 16:53:47 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 31E52E06F3; Thu, 19 Jul 2012 16:53:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 06A4BE06F3 for ; Thu, 19 Jul 2012 16:53:28 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4F0651B4060 for ; Thu, 19 Jul 2012 16:53:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 42374E543D for ; Thu, 19 Jul 2012 16:53:26 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1342716736.2c8f26987ba0e1fe111b45cd2d9566abb69372b9.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:overlay_wip commit in: roverlay/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/packageinfo.py X-VCS-Directories: roverlay/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 2c8f26987ba0e1fe111b45cd2d9566abb69372b9 X-VCS-Branch: overlay_wip Date: Thu, 19 Jul 2012 16:53:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: fd562950-362c-49cf-bb98-f4fb23700256 X-Archives-Hash: 1619bda2128b345f2b9daf523a4b86bf Message-ID: <20120719165326.BkwwHksyluc8jDZ7UhIt2EHp158-JLvAnRoOXzT2ijw@z> commit: 2c8f26987ba0e1fe111b45cd2d9566abb69372b9 Author: Andr=C3=A9 Erdmann mailerd de> AuthorDate: Thu Jul 19 16:52:16 2012 +0000 Commit: Andr=C3=A9 Erdmann mailerd de> CommitDate: Thu Jul 19 16:52:16 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/R_overlay.git= ;a=3Dcommit;h=3D2c8f2698 packageinfo: compare_version, has_key --- roverlay/packageinfo.py | 34 +++++++++++++++++++++++++++++++++- 1 files changed, 33 insertions(+), 1 deletions(-) diff --git a/roverlay/packageinfo.py b/roverlay/packageinfo.py index a2910c5..f9d26d1 100644 --- a/roverlay/packageinfo.py +++ b/roverlay/packageinfo.py @@ -114,6 +114,38 @@ class PackageInfo ( object ): return True # --- end of _writelock_acquire (...) --- =20 + def has_key ( self, *keys ): + for k in keys: + if k not in self._info: + # try harder - use get() with fallback value to see if value + # can be calculated + if self.get ( k, do_fallback=3DTrue ) is None: + return False + return True + # --- end of has_key (...) --- + + has =3D has_key + + def compare_version ( self, other_package ): + """Compares the version of two PackageInfo objects. + Returns 1 if self's version is higher, -1 if lower and 0 if equal. + + arguments: + * other_package -- + """ + if other_package is None: return 1 + + my_ver =3D self.get ( 'version', fallback_value=3D0 ) + other_ver =3D other_package.get ( 'version', fallback_value=3D0 ) + + if my_ver > other_ver: + return 1 + elif my_ver =3D=3D other_ver: + return 0 + else: + return -1 + # --- end of compare_version (...) --- + def get ( self, key, fallback_value=3DNone, do_fallback=3DFalse ): """Returns the value specified by key. The value is either calculated or taken from dict self._info. @@ -172,7 +204,7 @@ class PackageInfo ( object ): =20 =20 # fallback - if do_fallback: + if do_fallback or fallback_value is not None: return fallback_value =20 elif key_low in self.__class__.ALWAYS_FALLBACK: