Hs2Py constants: additional module qlang
authorJose A. Lopes <jabolopes@google.com>
Thu, 7 Nov 2013 09:48:12 +0000 (10:48 +0100)
committerJose A. Lopes <jabolopes@google.com>
Fri, 8 Nov 2013 16:59:38 +0000 (17:59 +0100)
Add constants from additional modules ('ganeti.qlang') to the Haskell
to Python constant generation.

Signed-off-by: Jose A. Lopes <jabolopes@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

autotools/convert-constants
lib/qlang.py
src/Ganeti/HsConstants.hs

index 8ec64a8..a0a9a2b 100755 (executable)
@@ -298,7 +298,6 @@ def Convert(module, prefix):
 
 
 def main():
-  print Convert(qlang, "qlang")
   print Convert(errors, "errors")
   print Convert(jstore, "jstore")
 
index 2352391..95eddb2 100644 (file)
@@ -32,44 +32,30 @@ converted to callable functions by L{query._CompileFilter}.
 """
 
 import re
-import string # pylint: disable=W0402
 import logging
 
 import pyparsing as pyp
 
+from ganeti import constants
 from ganeti import errors
 from ganeti import utils
 from ganeti import compat
 
 
-# Logic operators with one or more operands, each of which is a filter on its
-# own
-OP_OR = "|"
-OP_AND = "&"
-
-
-# Unary operators with exactly one operand
-OP_NOT = "!"
-OP_TRUE = "?"
-
-
-# Binary operators with exactly two operands, the field name and an
-# operator-specific value
-OP_EQUAL = "="
-OP_NOT_EQUAL = "!="
-OP_LT = "<"
-OP_LE = "<="
-OP_GT = ">"
-OP_GE = ">="
-OP_REGEXP = "=~"
-OP_CONTAINS = "=[]"
-
-
-#: Characters used for detecting user-written filters (see L{_CheckFilter})
-FILTER_DETECTION_CHARS = frozenset("()=/!~'\"\\<>" + string.whitespace)
-
-#: Characters used to detect globbing filters (see L{_CheckGlobbing})
-GLOB_DETECTION_CHARS = frozenset("*?")
+OP_OR = constants.QLANG_OP_OR
+OP_AND = constants.QLANG_OP_AND
+OP_NOT = constants.QLANG_OP_NOT
+OP_TRUE = constants.QLANG_OP_TRUE
+OP_EQUAL = constants.QLANG_OP_EQUAL
+OP_NOT_EQUAL = constants.QLANG_OP_NOT_EQUAL
+OP_LT = constants.QLANG_OP_LT
+OP_LE = constants.QLANG_OP_LE
+OP_GT = constants.QLANG_OP_GT
+OP_GE = constants.QLANG_OP_GE
+OP_REGEXP = constants.QLANG_OP_REGEXP
+OP_CONTAINS = constants.QLANG_OP_CONTAINS
+FILTER_DETECTION_CHARS = constants.QLANG_FILTER_DETECTION_CHARS
+GLOB_DETECTION_CHARS = constants.QLANG_GLOB_DETECTION_CHARS
 
 
 def MakeSimpleFilter(namefield, values):
index 4b4cd83..552f9c5 100644 (file)
@@ -4430,3 +4430,63 @@ luxiDefRwto = 60
 -- | 'WaitForJobChange' timeout
 luxiWfjcTimeout :: Int
 luxiWfjcTimeout = (luxiDefRwto - 1) `div` 2
+
+-- * Query language constants
+
+-- ** Logic operators with one or more operands, each of which is a
+-- filter on its own
+
+qlangOpAnd :: String
+qlangOpAnd = "&"
+
+qlangOpOr :: String
+qlangOpOr = "|"
+
+-- ** Unary operators with exactly one operand
+
+qlangOpNot :: String
+qlangOpNot = "!"
+
+qlangOpTrue :: String
+qlangOpTrue = "?"
+
+-- ** Binary operators with exactly two operands, the field name and
+-- an operator-specific value
+
+qlangOpContains :: String
+qlangOpContains = "=[]"
+
+qlangOpEqual :: String
+qlangOpEqual = "="
+
+qlangOpGe :: String
+qlangOpGe = ">="
+
+qlangOpGt :: String
+qlangOpGt = ">"
+
+qlangOpLe :: String
+qlangOpLe = "<="
+
+qlangOpLt :: String
+qlangOpLt = "<"
+
+qlangOpNotEqual :: String
+qlangOpNotEqual = "!="
+
+qlangOpRegexp :: String
+qlangOpRegexp = "=~"
+
+-- | Characters used for detecting user-written filters (see
+-- L{_CheckFilter})
+
+qlangFilterDetectionChars :: FrozenSet String
+qlangFilterDetectionChars =
+  ConstantUtils.mkSet ["!", " ", "\"", "\'",
+                       ")", "(", "\x0b", "\n",
+                       "\r", "\x0c", "/", "<",
+                       "\t", ">", "=", "\\", "~"]
+
+-- | Characters used to detect globbing filters
+qlangGlobDetectionChars :: FrozenSet String
+qlangGlobDetectionChars = ConstantUtils.mkSet ["*", "?"]