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 76ACD138200 for ; Fri, 2 Aug 2013 10:34:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 72F9AE0804; Fri, 2 Aug 2013 10:34:44 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C91FAE0804 for ; Fri, 2 Aug 2013 10:34: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 9D7AB33EBB4 for ; Fri, 2 Aug 2013 10:34:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 24061E545E for ; Fri, 2 Aug 2013 10:34: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: <1375438672.43ab1d2328ee2968dc0d5076f33629f859e12718.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/packageinfo.py roverlay/versiontuple.py X-VCS-Directories: roverlay/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 43ab1d2328ee2968dc0d5076f33629f859e12718 X-VCS-Branch: master Date: Fri, 2 Aug 2013 10:34: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: 8fc7ca54-b80f-481a-97a0-76419b11b39f X-Archives-Hash: a66edaab3bad4eb59c9e0a652bd3794e commit: 43ab1d2328ee2968dc0d5076f33629f859e12718 Author: André Erdmann mailerd de> AuthorDate: Fri Aug 2 10:17:52 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Fri Aug 2 10:17:52 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=43ab1d23 support suffixes $PV when importing ebuilds Selfdep validation may fail/ignore when dealing with import ebuilds with a version suffix ("_pre..." etc.). --- roverlay/packageinfo.py | 18 +++++++++++------- roverlay/versiontuple.py | 30 +++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/roverlay/packageinfo.py b/roverlay/packageinfo.py index 752f996..704807e 100644 --- a/roverlay/packageinfo.py +++ b/roverlay/packageinfo.py @@ -805,17 +805,21 @@ class PackageInfo ( object ): pv_str, DONT_CARE, pr_str = pvr.partition ( '-r' ) pv, DONT_CARE, pv_suffix = pv_str.partition ( '_' ) + # non-digit chars in pv are not supported + pv_list = [ int(z) for z in pv.split ( '.' ) ] + if pv_suffix: # not supported - raise NotImplementedError ( - "version suffix {!r} cannot be preserved for $PVR {!r}".format ( - pv_suffix, pvr + self._info ['version'] = ( + roverlay.versiontuple.SuffixedIntVersionTuple ( + pv_list, pv_suffix ) ) - # non-digit chars in pv are unsupported, too - self._info ['version'] = roverlay.versiontuple.IntVersionTuple ( - int ( z ) for z in pv.split ( '.' ) - ) + else: + self._info ['version'] = ( + roverlay.versiontuple.IntVersionTuple ( pv_list ) + ) + self._info ['rev'] = int ( pr_str ) if pr_str else 0 self._info ['ebuild_verstr'] = pvr diff --git a/roverlay/versiontuple.py b/roverlay/versiontuple.py index 6586088..579471f 100644 --- a/roverlay/versiontuple.py +++ b/roverlay/versiontuple.py @@ -67,9 +67,9 @@ def pkgver_decorator ( func ): class VersionTuple ( tuple ): - def __init__ ( self, *args, **kwargs ): - super ( VersionTuple, self ).__init__ ( *args, **kwargs ) - # --- end of __init__ (...) --- + def __new__ ( cls, gen_tuple, *args, **kwargs ): + return super ( VersionTuple, cls ).__new__ ( cls, gen_tuple ) + # --- end of __new__ (...) --- def get_comparator ( self, mode ): """Returns a function "this ~ other" that returns @@ -228,4 +228,28 @@ class IntVersionTuple ( VersionTuple ): return NotImplemented # --- end of __gt__ (...) --- + def __str__ ( self ): + return '.'.join ( str(k) for k in self ) + # --- end of __str__ ( self ) + # --- end of IntVersionTuple --- + +class SuffixedIntVersionTuple ( VersionTuple ): + # inherit VersionTuple: does not implement comparision functions + + def __init__ ( self, gen_tuple, suffix ): + super ( SuffixedIntVersionTuple, self ).__init__ ( gen_tuple ) + self.suffix = suffix + # --- end of __init__ (...) --- + + def get_suffix_str ( self ): + ret = str ( self.suffix ) + if not ret or ret[0] == '_': + return ret + else: + return '_' + ret + # --- end of get_suffix_str (...) --- + + def __str__ ( self ): + return '.'.join ( str(k) for k in self ) + self.get_suffix_str() + # --- end of __str__ (...) ----