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 A93451381F3 for ; Mon, 19 Aug 2013 15:43:45 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4F270E0EF0; Mon, 19 Aug 2013 15:43:18 +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 B6EB3E0EF0 for ; Mon, 19 Aug 2013 15:43:02 +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 8849C33EBC3 for ; Mon, 19 Aug 2013 15:43:01 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id B2538E5469 for ; Mon, 19 Aug 2013 15:42:58 +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: <1376926044.af8d62d1c69301ee152475c63328ff22a4563bea.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/packagerules/parser/context/match.py X-VCS-Directories: roverlay/packagerules/parser/context/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: af8d62d1c69301ee152475c63328ff22a4563bea X-VCS-Branch: master Date: Mon, 19 Aug 2013 15:42:58 +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: e99e71cd-395d-4252-af48-20fb25988dfc X-Archives-Hash: dfe25f1ee794824a43f380e6eed1d4ab commit: af8d62d1c69301ee152475c63328ff22a4563bea Author: André Erdmann mailerd de> AuthorDate: Mon Aug 19 15:27:24 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Mon Aug 19 15:27:24 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=af8d62d1 package rules, match block: support true/false This makes the always-true/always-false acceptors from roverlay.packagerules.acceptors.trivial available. Note that the "any" keyword is now used for "always true" and the "all" keyword has been removed to avoid confusion. Documentation needs to reflect these changes (todo). --- roverlay/packagerules/parser/context/match.py | 52 ++++++++++++++++++++------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/roverlay/packagerules/parser/context/match.py b/roverlay/packagerules/parser/context/match.py index 82333eb..00fa0e6 100644 --- a/roverlay/packagerules/parser/context/match.py +++ b/roverlay/packagerules/parser/context/match.py @@ -9,6 +9,7 @@ import roverlay.strutil import roverlay.packagerules.abstract.acceptors import roverlay.packagerules.parser.context.base import roverlay.packagerules.acceptors.util +import roverlay.packagerules.acceptors.trivial from roverlay.packagerules.acceptors import stringmatch @@ -48,17 +49,21 @@ class RuleMatchContext ( # used to set the "boolean type" of a RuleMatchContext, i.e. which # boolean function (acceptor compound class) will be used to combine # all read rules - BOOL_AND = 0 - BOOL_OR = 1 - BOOL_XOR1 = 2 - BOOL_NOR = 3 + BOOL_AND = 0 + BOOL_OR = 1 + BOOL_XOR1 = 2 + BOOL_NOR = 3 + BOOL_VERUM = 4 + BOOL_FALSUM = 5 # dict ( => ) _BOOL_MAP = { - BOOL_AND : roverlay.packagerules.abstract.acceptors.Acceptor_AND, - BOOL_OR : roverlay.packagerules.abstract.acceptors.Acceptor_OR, - BOOL_XOR1 : roverlay.packagerules.abstract.acceptors.Acceptor_XOR1, - BOOL_NOR : roverlay.packagerules.abstract.acceptors.Acceptor_NOR, + BOOL_AND : roverlay.packagerules.abstract.acceptors.Acceptor_AND, + BOOL_OR : roverlay.packagerules.abstract.acceptors.Acceptor_OR, + BOOL_XOR1 : roverlay.packagerules.abstract.acceptors.Acceptor_XOR1, + BOOL_NOR : roverlay.packagerules.abstract.acceptors.Acceptor_NOR, + BOOL_VERUM : roverlay.packagerules.acceptors.trivial.TrueAcceptor, + BOOL_FALSUM : roverlay.packagerules.acceptors.trivial.FalseAcceptor, } # operators used for value comparision @@ -68,10 +73,18 @@ class RuleMatchContext ( OP_REGEX_EXACT = frozenset (( '~=', '=~' )) # keywords that introduce a nested match block - KEYWORDS_AND = frozenset (( 'and', 'all', '&&' )) - KEYWORDS_OR = frozenset (( 'or', 'any', '||' )) - KEYWORDS_XOR1 = frozenset (( 'xor1', 'xor', '^^' )) - KEYWORDS_NOR = frozenset (( 'nor', 'none' )) + # + # Note: + # * As of 2013-08-19, the "all" keyword has been removed and + # "any" is no longer a keyword for "or" + # (it now "points" to the "always true" acceptor) + # + KEYWORDS_AND = frozenset ({ 'and', '&&' }) + KEYWORDS_OR = frozenset ({ 'or', '||' }) + KEYWORDS_XOR1 = frozenset ({ 'xor1', 'xor', '^^' }) + KEYWORDS_NOR = frozenset ({ 'nor', 'none' }) + KEYWORDS_VERUM = frozenset ({ "any", "true", }) + KEYWORDS_FALSUM = frozenset ({ "none", "false", }) # dict ( # keywords => ( @@ -127,6 +140,7 @@ class RuleMatchContext ( ) self.priority = priority self._matches = list() + # active == accepts input self._active = True # --- end of __init__ (...) --- @@ -151,7 +165,19 @@ class RuleMatchContext ( elif match_depth == self.level: s_low = s.lower() - if s_low in self.KEYWORDS_AND: + if s_low in self.KEYWORDS_VERUM: + # match branch creation could be optimized here + # (X or True <=> True, X and True <=> X a.s.o.) + # + self._new_nested ( bool_type=self.BOOL_VERUM, priority=lino ) + self.get_nested()._active = False + # or: _new_nested(...)._active = False + + elif s_low in self.KEYWORDS_FALSUM: + self._new_nested ( bool_type=self.BOOL_FALSUM, priority=lino ) + self.get_nested()._active = False + + elif s_low in self.KEYWORDS_AND: self._new_nested ( bool_type=self.BOOL_AND, priority=lino ) elif s_low in self.KEYWORDS_OR: