public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/
@ 2013-04-25 16:44 André Erdmann
  0 siblings, 0 replies; 7+ messages in thread
From: André Erdmann @ 2013-04-25 16:44 UTC (permalink / raw
  To: gentoo-commits

commit:     9f2e075f08aba1e01b534d696b9297410ebacc1a
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Tue Apr 23 00:08:01 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Tue Apr 23 00:08:01 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=9f2e075f

packagerules/parser/context: fix InvalidContext

BaseContext.InvalidContext should derive from BaseException.

---
 roverlay/packagerules/parser/context/base.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/roverlay/packagerules/parser/context/base.py b/roverlay/packagerules/parser/context/base.py
index 3abb6e8..6c18faa 100644
--- a/roverlay/packagerules/parser/context/base.py
+++ b/roverlay/packagerules/parser/context/base.py
@@ -6,7 +6,7 @@
 
 class BaseContext ( object ):
 
-	class InvalidContext ( object ):
+	class InvalidContext ( Exception ):
 		pass
 	# --- end of InvalidContext ---
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/
@ 2013-06-13 16:34 André Erdmann
  0 siblings, 0 replies; 7+ messages in thread
From: André Erdmann @ 2013-06-13 16:34 UTC (permalink / raw
  To: gentoo-commits

commit:     b2bb893af081ff93b8bcb28539f94bb678555363
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Tue Jun  4 20:38:44 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Tue Jun  4 20:38:44 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=b2bb893a

pkg rule parser, context/match: ebuild_name, name

The "ebuild_name" match keyword can be used to match a package's ebuild name,
which is not necessarily the same as the package name.

The "name" keyword is no longer an alias to package_name!

---
 roverlay/packagerules/parser/context/match.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/roverlay/packagerules/parser/context/match.py b/roverlay/packagerules/parser/context/match.py
index c294220..d4c206d 100644
--- a/roverlay/packagerules/parser/context/match.py
+++ b/roverlay/packagerules/parser/context/match.py
@@ -97,8 +97,12 @@ class RuleMatchContext (
       'package_name' : (
          None, roverlay.packagerules.acceptors.util.get_package_name,
       ),
+      # FIXME: update docs! name is no longer an aliased to package_name
       'name' : (
-         None, roverlay.packagerules.acceptors.util.get_package_name,
+         None, roverlay.packagerules.acceptors.util.get_ebuild_name,
+      ),
+      'ebuild_name' : (
+         None, roverlay.packagerules.acceptors.util.get_ebuild_name,
       ),
    }
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/
  2013-06-05 18:08 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
@ 2013-06-13 16:34 ` André Erdmann
  0 siblings, 0 replies; 7+ messages in thread
From: André Erdmann @ 2013-06-13 16:34 UTC (permalink / raw
  To: gentoo-commits

commit:     69d3d6eebf2bd33fbb135be71004791a37f70ba1
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Jun  5 17:57:51 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Jun  5 17:57:51 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=69d3d6ee

package rule parser, set/rename: ActionInvalid

---
 roverlay/packagerules/parser/context/action.py | 45 ++++++++++++++++----------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/roverlay/packagerules/parser/context/action.py b/roverlay/packagerules/parser/context/action.py
index c58f7ca..22936cc 100644
--- a/roverlay/packagerules/parser/context/action.py
+++ b/roverlay/packagerules/parser/context/action.py
@@ -14,14 +14,22 @@ import roverlay.packagerules.actions.relocate
 import roverlay.packagerules.actions.trace
 import roverlay.packagerules.parser.context.base
 
-class ActionUnknown ( ValueError ):
+class RuleActionException ( ValueError ):
+   pass
+# --- end of RuleActionException ---
+
+class ActionUnknown ( RuleActionException ):
    pass
 # --- end of ActionUnknown ---
 
-class ActionNeedsValue ( ValueError ):
+class ActionNeedsValue ( RuleActionException ):
    pass
 # --- end of ActionNeedsValue ---
 
+class ActionInvalid ( RuleActionException ):
+   pass
+# --- end of ActionInvalid ---
+
 
 class RuleActionContext (
    roverlay.packagerules.parser.context.base.BaseContext
@@ -50,18 +58,19 @@ class RuleActionContext (
    #
    DEFAULT_MODIFY_INFO_ACTIONS = (
       roverlay.packagerules.actions.info.InfoSetToAction,
-      roverlay.packagerules.actions.info.LazyInfoRenameAction
+      roverlay.packagerules.actions.info.InfoRenameAction,
    )
 
-   # dict { key => None | { None | SetTo_Action, None | Rename_Action }
-   #   where None is "use default action(s)"
+   # dict { key => None | ( None|False|SetTo_Action, None|False|Rename_Action )
+   #   where None  is "use default action(s)"
+   #   and   False is "invalid"/"not supported"
+   #
+   # (see comment in packageinfo.py concerning keys that exist when calling
+   #  apply_action() and enable lazy actions if necessary)
    #
    MODIFIABLE_INFO_KEYS = {
-      'name' : (
-         None,
-         roverlay.packagerules.actions.info.InfoRenameAction
-      ),
-      'category' : None,
+      'name'     : None,
+      'category' : ( None, False ),
       'destfile' : (
          None,
          roverlay.packagerules.actions.relocate.SrcDestRenameAction
@@ -141,17 +150,19 @@ class RuleActionContext (
 
          # ( ( cls_tuple or <default> ) [action_type] ) or <default>
          action_cls = (
-            (
-               self.MODIFIABLE_INFO_KEYS [key]
-               or self.DEFAULT_MODIFY_INFO_ACTIONS
-            ) [action_type]
-            or self.DEFAULT_MODIFY_INFO_ACTIONS [action_type]
-         )
+            self.MODIFIABLE_INFO_KEYS [key]
+            or self.DEFAULT_MODIFY_INFO_ACTIONS
+         ) [action_type]
+
+         if action_cls is None:
+            action_cls = self.DEFAULT_MODIFY_INFO_ACTIONS [action_type]
       except KeyError:
          raise ActionUnknown ( orig_str )
 
       # create and add action
-      if action_type == 0:
+      if action_cls is False:
+         raise ActionInvalid ( orig_str )
+      elif action_type == 0:
          # info action (1 arg)
          value = roverlay.strutil.unquote ( value )
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/
@ 2013-06-13 16:34 André Erdmann
  0 siblings, 0 replies; 7+ messages in thread
From: André Erdmann @ 2013-06-13 16:34 UTC (permalink / raw
  To: gentoo-commits

commit:     ad1e9bcc9a2f64c9de4a8ff210628d78e8264c16
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Tue Jun  4 20:55:27 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Tue Jun  4 20:55:27 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=ad1e9bcc

package rule parser, actions: parse info actions

This commit adds support for parsing actions that modify package info dicts.

Currently, a package's ebuild name, category and src_uri destfile can be set
to a specific value or edited using a sed-like regex statement.

The basic syntax for set-to-value is

* set <key> <value>
* set_<key> <value>

regex-rename syntax:
* set <key> s/<regex>/<replacement>/[<flags>]
* set_<key> ...

"/" can be replaced by any other char (but --print-package-rules will always use
"/").

<flags> (e.g. "g") is not implemented. All occurences of <regex> will be
replaced.

---
 roverlay/packagerules/parser/context/action.py | 173 +++++++++++++++++++++++--
 1 file changed, 164 insertions(+), 9 deletions(-)

diff --git a/roverlay/packagerules/parser/context/action.py b/roverlay/packagerules/parser/context/action.py
index f9a2e80..c58f7ca 100644
--- a/roverlay/packagerules/parser/context/action.py
+++ b/roverlay/packagerules/parser/context/action.py
@@ -4,9 +4,13 @@
 # Distributed under the terms of the GNU General Public License;
 # either version 2 of the License, or (at your option) any later version.
 
+import re
+
 import roverlay.strutil
 
 import roverlay.packagerules.actions.evar
+import roverlay.packagerules.actions.info
+import roverlay.packagerules.actions.relocate
 import roverlay.packagerules.actions.trace
 import roverlay.packagerules.parser.context.base
 
@@ -41,11 +45,165 @@ class RuleActionContext (
       'keywords' : roverlay.packagerules.actions.evar.KeywordsEvarAction,
    }
 
+   # default info set-to/rename actions
+   #  using the lazy variant for renaming
+   #
+   DEFAULT_MODIFY_INFO_ACTIONS = (
+      roverlay.packagerules.actions.info.InfoSetToAction,
+      roverlay.packagerules.actions.info.LazyInfoRenameAction
+   )
+
+   # dict { key => None | { None | SetTo_Action, None | Rename_Action }
+   #   where None is "use default action(s)"
+   #
+   MODIFIABLE_INFO_KEYS = {
+      'name' : (
+         None,
+         roverlay.packagerules.actions.info.InfoRenameAction
+      ),
+      'category' : None,
+      'destfile' : (
+         None,
+         roverlay.packagerules.actions.relocate.SrcDestRenameAction
+      ),
+   }
+
+   # TODO / Notes:
+   #
+   # * "combined" actions, e.g. name,category as "pseudo" actions?
+   #
+   # dict { pseudo_key => tuple ( argparse_function, set { real key[s] } ) }
+   #
+##   DEMUX_INFO_KEYS = {
+##      'cp' : ( argstr_parse(), { 'name', 'category', } )
+##   }
+
    def __init__ ( self, namespace ):
       super ( RuleActionContext, self ).__init__ ( namespace )
       self._actions = list()
    # --- end of __init__ (...) ---
 
+   def _add_as_info_action ( self, keyword, argstr, orig_str, lino ):
+      """Tries to add <keyword, argstr> as package info-manipulating action.
+
+      Returns true if such an action has been created and added, else False.
+      Invalid values/lines will be catched here. A return value of False
+      simply means that keyword/argstr do not represent an info action.
+
+      arguments:
+      * keyword  --
+      * argstr   --
+      * orig_str --
+      * lino     --
+
+      Raises:
+      * ActionUnknown
+      * ActionNeedsValue
+      """
+      # get action_type_str (and, possibly, key)
+      action_type_str, sepa, key = keyword.partition ( "_" )
+      action_type_str = action_type_str.lower()
+
+      if action_type_str == "set":
+         # is a set-to info action, continue
+         action_type = 0
+      elif action_type_str == "rename":
+         # is a rename info action, continue
+         action_type = 1
+      else:
+         # not an info action
+         return False
+      # -- end if;
+
+      if not sepa:
+         # get key from argstr
+         argv = roverlay.strutil.split_whitespace ( argstr, maxsplit=1 )
+         if argv:
+            key = roverlay.strutil.unquote ( argv [0].lower() )
+            if not key:
+               # better safe than sorry ;)
+               #return False
+               raise ActionUnknown ( orig_str )
+         else:
+            #return False
+            raise ActionUnknown ( orig_str )
+
+
+         # dont unquote value here,
+         #  this operation might depend on key in future
+         value = argv [1]
+      else:
+         value = argstr
+      # -- end if;
+
+      # get action class (raises KeyError)
+      try:
+
+         # ( ( cls_tuple or <default> ) [action_type] ) or <default>
+         action_cls = (
+            (
+               self.MODIFIABLE_INFO_KEYS [key]
+               or self.DEFAULT_MODIFY_INFO_ACTIONS
+            ) [action_type]
+            or self.DEFAULT_MODIFY_INFO_ACTIONS [action_type]
+         )
+      except KeyError:
+         raise ActionUnknown ( orig_str )
+
+      # create and add action
+      if action_type == 0:
+         # info action (1 arg)
+         value = roverlay.strutil.unquote ( value )
+
+         if value:
+            self._actions.append ( action_cls ( key, value, lino ) )
+         else:
+            raise ActionNeedsValue ( orig_str )
+      else:
+         # rename action (1 arg)
+         #  sed-like replace statement "s/a/b/flags?"
+         #
+         # FIXME/TODO *** flags are not implemented ***
+         #
+         # len ( value ) >= len (
+         #    "s" + sepa + len(a)>=1 + sepa + len(b)>=1 + sepa + len(flags)>=0
+         # )
+         # => 6 relevant parts (3x sepa, 2x value), len (value) has to be > 5
+         #
+
+         value = roverlay.strutil.unquote ( value )
+
+         if len ( value ) > 5 and value[0] == 's' and value[1] == value[-1]:
+
+            # double-escaped backslash
+            re_splitter = self.namespace.get_object (
+               re.compile, '(?<!\\\)' + value [1]
+            )
+
+            # (redef argv)
+            argv = re_splitter.split ( value, maxsplit=3 )
+
+            if len ( argv ) > 3 and all ( argv[:4] ):
+               raise NotImplementedError ( "flags are not supported yet." )
+
+            elif len ( argv ) > 2 and all ( argv[:3] ):
+               self._actions.append (
+                  action_cls (
+                     key,
+                     self.namespace.get_object ( re.compile, argv [1] ),
+                     argv [2],
+                     lino
+                  )
+               )
+            else:
+               raise ActionNeedsValue ( orig_str )
+         else:
+            raise ActionNeedsValue ( orig_str )
+      # -- end if;
+
+      return True
+   # --- end of _add_as_info_action (...) ---
+
    def feed ( self, _str, lino ):
       """Feeds this action block with input.
 
@@ -74,31 +232,28 @@ class RuleActionContext (
          if argv [0] in self.KEYWORDS_ACTION_TRACE:
             if len ( argv ) > 1 and argv [1]:
                self._actions.append (
-                  self.namespace.get_object (
-                     roverlay.packagerules.actions.trace.TraceAction,
+                  roverlay.packagerules.actions.trace.TraceAction (
                      roverlay.strutil.unquote ( argv [1] ),
                      lino
                   )
                )
             else:
                self._actions.append (
-                  self.namespace.get_object (
-                     roverlay.packagerules.actions.trace.MarkAsModifiedAction,
+                  roverlay.packagerules.actions.trace.MarkAsModifiedAction (
                      lino
                   )
                )
 
+         elif self._add_as_info_action ( argv [0], argv [1], _str, lino ):
+            pass
+
          else:
             evar_cls = self.KEYWORDS_EVAR.get ( argv [0], None )
 
             try:
                if evar_cls:
                   self._actions.append (
-                     self.namespace.get_object (
-                        evar_cls,
-                        roverlay.strutil.unquote ( argv [1] ),
-                        lino
-                     )
+                     evar_cls ( roverlay.strutil.unquote ( argv [1] ), lino )
                   )
                else:
                   raise ActionUnknown ( _str )


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/
@ 2013-08-01 17:14 André Erdmann
  0 siblings, 0 replies; 7+ messages in thread
From: André Erdmann @ 2013-08-01 17:14 UTC (permalink / raw
  To: gentoo-commits

commit:     66b21d7afd3115f7b349078825d4a784aa4a2c4f
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Thu Aug  1 14:29:09 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Thu Aug  1 14:30:17 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=66b21d7a

package rule, bind no-op statement to BaseContext

---
 roverlay/packagerules/parser/context/action.py | 3 +--
 roverlay/packagerules/parser/context/base.py   | 2 ++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/roverlay/packagerules/parser/context/action.py b/roverlay/packagerules/parser/context/action.py
index 49ed7db..febe88b 100644
--- a/roverlay/packagerules/parser/context/action.py
+++ b/roverlay/packagerules/parser/context/action.py
@@ -46,7 +46,6 @@ class RuleActionContext (
       'trace',
    })
 
-   KEYWORDS_NO_ACTION = frozenset ({ 'pass', 'null', })
 
    # dict ( <keyword> => <evar class> )
    # Dict of evar action keywords (with corresponding classes)
@@ -227,7 +226,7 @@ class RuleActionContext (
       Raises:
       * InvalidContext
       """
-      if _str in self.KEYWORDS_NO_ACTION:
+      if _str in self.KEYWORDS_NOP_STATEMENT:
          pass
       elif _str in self.KEYWORDS_ACTION_IGNORE:
          if not self._actions:

diff --git a/roverlay/packagerules/parser/context/base.py b/roverlay/packagerules/parser/context/base.py
index 9bd97b7..90f79b4 100644
--- a/roverlay/packagerules/parser/context/base.py
+++ b/roverlay/packagerules/parser/context/base.py
@@ -6,6 +6,8 @@
 
 class BaseContext ( object ):
 
+   KEYWORDS_NOP_STATEMENT = frozenset ({ 'pass', 'null', })
+
    class InvalidContext ( Exception ):
       pass
    # --- end of InvalidContext ---


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/
@ 2013-08-19 15:42 André Erdmann
  0 siblings, 0 replies; 7+ messages in thread
From: André Erdmann @ 2013-08-19 15:42 UTC (permalink / raw
  To: gentoo-commits

commit:     539bc31a0b81d40efc812642f2682c98170cb1d1
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Mon Aug 19 15:32:28 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Mon Aug 19 15:32:28 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=539bc31a

package rules, actions: run self-test

---
 roverlay/packagerules/parser/context/action.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/roverlay/packagerules/parser/context/action.py b/roverlay/packagerules/parser/context/action.py
index febe88b..1828754 100644
--- a/roverlay/packagerules/parser/context/action.py
+++ b/roverlay/packagerules/parser/context/action.py
@@ -93,6 +93,11 @@ class RuleActionContext (
       self._actions = list()
    # --- end of __init__ (...) ---
 
+   def _add_action ( self, action ):
+      if action.do_test ( return_on_error=False ):
+         self._actions.append ( action )
+   # --- end of _add_action (...) ---
+
    def _add_as_info_action ( self, keyword, argstr, orig_str, lino ):
       """Tries to add <keyword, argstr> as package info-manipulating action.
 
@@ -168,7 +173,7 @@ class RuleActionContext (
          value = roverlay.strutil.unquote ( value )
 
          if value:
-            self._actions.append ( action_cls ( key, value, lino ) )
+            self._add_action ( action_cls ( key, value, lino ) )
          else:
             raise ActionNeedsValue ( orig_str )
       else:
@@ -199,7 +204,7 @@ class RuleActionContext (
                raise NotImplementedError ( "flags are not supported yet." )
 
             elif len ( argv ) > 2 and all ( argv[:3] ):
-               self._actions.append (
+               self._add_action (
                   action_cls (
                      key,
                      self.namespace.get_object ( re.compile, argv [1] ),
@@ -245,14 +250,14 @@ class RuleActionContext (
 
          if argv [0] in self.KEYWORDS_ACTION_TRACE:
             if len ( argv ) > 1 and argv [1]:
-               self._actions.append (
+               self._add_action (
                   roverlay.packagerules.actions.trace.TraceAction (
                      roverlay.strutil.unquote ( argv [1] ),
                      lino
                   )
                )
             else:
-               self._actions.append (
+               self._add_action (
                   roverlay.packagerules.actions.trace.MarkAsModifiedAction (
                      lino
                   )
@@ -268,7 +273,7 @@ class RuleActionContext (
 
             try:
                if evar_cls:
-                  self._actions.append (
+                  self._add_action (
                      evar_cls ( roverlay.strutil.unquote ( argv [1] ), lino )
                   )
                else:


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/
@ 2013-08-19 15:42 André Erdmann
  0 siblings, 0 replies; 7+ messages in thread
From: André Erdmann @ 2013-08-19 15:42 UTC (permalink / raw
  To: gentoo-commits

commit:     af8d62d1c69301ee152475c63328ff22a4563bea
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Mon Aug 19 15:27:24 2013 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> 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 type> => <acceptor compound class> )
    _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:


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-08-19 15:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-19 15:42 [gentoo-commits] proj/R_overlay:master commit in: roverlay/packagerules/parser/context/ André Erdmann
  -- strict thread matches above, loose matches on Subject: below --
2013-08-19 15:42 André Erdmann
2013-08-01 17:14 André Erdmann
2013-06-13 16:34 André Erdmann
2013-06-13 16:34 André Erdmann
2013-06-05 18:08 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-06-13 16:34 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-04-25 16:44 André Erdmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox