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 BB98D1381F3 for ; Thu, 21 Apr 2016 16:54:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E038B21C016; Thu, 21 Apr 2016 16:54:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 27553E0863 for ; Thu, 21 Apr 2016 16:54:41 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F34E8340C97 for ; Thu, 21 Apr 2016 16:54:39 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C2230209C for ; Thu, 21 Apr 2016 16:54:35 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1461257369.d97a0ffb07536f475cec4b33151446a5da9a83c1.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/, pym/repoman/modules/scan/metadata/, ... X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/fuse.py pym/repoman/modules/scan/ebuild/ebuild.py pym/repoman/modules/scan/ebuild/isebuild.py pym/repoman/modules/scan/metadata/unused.py pym/repoman/scanner.py X-VCS-Directories: pym/repoman/modules/scan/ebuild/ pym/repoman/ pym/repoman/modules/scan/metadata/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: d97a0ffb07536f475cec4b33151446a5da9a83c1 X-VCS-Branch: repoman Date: Thu, 21 Apr 2016 16:54:35 +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: cff2ca55-5008-48f9-b4be-226e7f13ae28 X-Archives-Hash: be149d234616788d17730feb9cebfbe4 commit: d97a0ffb07536f475cec4b33151446a5da9a83c1 Author: Brian Dolbec gentoo org> AuthorDate: Tue Mar 15 18:40:06 2016 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Thu Apr 21 16:49:29 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d97a0ffb repoman: Create a new boolean Fuse type Create a Fuse type which implememts a boolean as a one time fuse. The Fuse is initialized True, then is pop()'d to become False. Once the Fuse is blown, it can not be reset to True. Convert the use of the dynamic_data variable 'allvalid' to a Fuse instance. pym/repoman/fuse.py | 68 +++++++++++++++++++++++++++++ pym/repoman/modules/scan/ebuild/ebuild.py | 7 ++- pym/repoman/modules/scan/ebuild/isebuild.py | 13 +++--- pym/repoman/modules/scan/metadata/unused.py | 2 +- pym/repoman/scanner.py | 2 + 5 files changed, 83 insertions(+), 9 deletions(-) diff --git a/pym/repoman/fuse.py b/pym/repoman/fuse.py new file mode 100644 index 0000000..ac864fd --- /dev/null +++ b/pym/repoman/fuse.py @@ -0,0 +1,68 @@ + +''' +fuse.py + +A tiny one-time-fuse class that uses a boolean to mimic the property of +an electrical fuse. IT's good (True) until it is popped (bad, False). +It is not resetable. +''' + + +class Fuse(object): + '''A One time fuse style boolean instance''' + + __slots__ = ('_state') + + def __init__(self): + self._state = True + + def pop(self): + '''Blow's the fuse state (makes it False)''' + self._state = False + + def __repr__(self): + '''x.__repr__() <==> repr(x)''' + return repr(self._state>0) + + def __str__(self): + '''x.__str__() <==> str(x)''' + return ['False', 'True'][self._state] + + def __bool__(self): + '''self != 0''' + return self._state != 0 + + def __nonzero__(self): + '''self != 0''' + return self._state != 0 + + def __abs__(self): + '''x.__abs__() <==> abs(x)''' + return [0, 1] [self._state] + + def __int__(self): + '''int(self)''' + return [0, 1][self._state] + + def __eq__(self, value): + '''Return self==value.''' + return self._state == value + + def __ne__(self, value): + '''Return self!=value.''' + return self._state != value + + def __ge__(self, value): + '''Return self>=value.''' + return self._state >= value + + def __gt__(self, value): + return self._state > value + + def __le__(self, value): + '''Return self<=value.''' + return self._state <= value + + def __lt__(self, value): + '''Return self self.modules or some other ordered list for mod in ['Manifests', 'IsEbuild', 'KeywordChecks', 'FileChecks',