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.60) (envelope-from ) id 1SkEmd-0006wc-MI for garchives@archives.gentoo.org; Thu, 28 Jun 2012 13:29:20 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 19C70E072E; Thu, 28 Jun 2012 13:29:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id DE608E072E for ; Thu, 28 Jun 2012 13:29:06 +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 416C01B4053 for ; Thu, 28 Jun 2012 13:29:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id EC31DE543F for ; Thu, 28 Jun 2012 13:29:03 +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: <1340890098.9ca4636cfbf9020b513ebab8e1d5ee4fefef8e47.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/ebuild/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/ebuild/abstractcomponents.py X-VCS-Directories: roverlay/ebuild/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 9ca4636cfbf9020b513ebab8e1d5ee4fefef8e47 X-VCS-Branch: master Date: Thu, 28 Jun 2012 13:29:03 +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: b7a9d79a-c325-4235-8763-a566ea44c5d6 X-Archives-Hash: aeb7992db86fa731a9fca9a1cfbdbcc9 commit: 9ca4636cfbf9020b513ebab8e1d5ee4fefef8e47 Author: Andr=C3=A9 Erdmann mailerd de> AuthorDate: Thu Jun 28 13:28:18 2012 +0000 Commit: Andr=C3=A9 Erdmann mailerd de> CommitDate: Thu Jun 28 13:28:18 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/R_overlay.git= ;a=3Dcommit;h=3D9ca4636c ebuild: don't print empty vars (DEPEND=3D"" etc.) modified: roverlay/ebuild/abstractcomponents.py --- roverlay/ebuild/abstractcomponents.py | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/roverlay/ebuild/abstractcomponents.py b/roverlay/ebuild/abst= ractcomponents.py index 019c252..5437dfc 100644 --- a/roverlay/ebuild/abstractcomponents.py +++ b/roverlay/ebuild/abstractcomponents.py @@ -37,9 +37,19 @@ class ListValue ( object ): self.set_value ( value ) # --- end of __init__ (...) --- =20 + def _accept_value ( self, value ): + if value is None: + return False + # "not str or len > 0" will raise exceptions for integers etc. + elif isinstance ( value, str ) and len ( value ) =3D=3D 0: + return False + else: + return True + # --- end _accept_value (...) --- + def __len__ ( self ): l =3D len ( self.value ) - return l if self.empty_value is None else l - 1 + return max ( 0, l if self.empty_value is None else l - 1 ) =20 def set_level ( self, level ): """Sets the indention level.""" @@ -54,12 +64,14 @@ class ListValue ( object ): self.value =3D list() if self.empty_value is not None: self.value.append ( self.empty_value ) - self.add_value ( value ) + + if self._accept_value ( value ): + self.add_value ( value ) # --- end of set_value (...) --- =20 def add_value ( self, value ): """Adds/Appends a value.""" - if value is None: + if not self._accept_value ( value ): pass elif listlike ( value ): self.value.extend ( value ) @@ -119,7 +131,12 @@ class EbuildVar ( object ): (EbuildVar's active() returns always True, derived classes may override this.) """ - return True + if hasattr ( self, 'enabled' ): + return self.enabled + elif hasattr ( self.value, '__len__' ): + return len ( self.value ) > 0 + else: + return True =20 def __str__ ( self ): return '%s%s=3D"%s"' % ( self.indent, self.name, self.value )