Exemple #1
0
REGEX_VALUE_IN_QUOTES = '\"[^\"]*\"\s*'
REGEX_VALUE_IN_APOSTROPHES = "'[^']*'\s*"
REGEX_FLOATING_NUMBER = '[-]?\d*\.\d+'
REGEX_INTEGER = '[-]?\d+'
REGEX_TRUE = '(?i)true'
REGEX_FALSE = '(?i)false'
REGEX_NULL = 'null'

# REGEX_FLOATING_NUMBER must go before REGEX_INTEGER
REGEX_INLINE_PARAM_VARIATIONS = [
    REGEX_VALUE_IN_BRACKETS, REGEX_VALUE_IN_QUOTES, REGEX_VALUE_IN_APOSTROPHES,
    REGEX_FLOATING_NUMBER, REGEX_INTEGER, REGEX_TRUE, REGEX_FALSE, REGEX_NULL
]

REGEX_INLINE_PARAM_VARIATIONS.extend(
    [e._regex_pattern for e in expr_base.get_evaluators().values()])

REGEX_INLINE_PARAMS = '([\w]+)=(%s)' % '|'.join(REGEX_INLINE_PARAM_VARIATIONS)


def parse_inline_params(s, preserve_order=True):
    # Use a list to preserve order.
    params = [] if preserve_order else {}

    if s is None or not isinstance(s, six.string_types) or s == str():
        return params

    for k, v in re.findall(REGEX_INLINE_PARAMS, s):
        # Remove leading and trailing whitespaces.
        v = v.strip()
Exemple #2
0
 def is_action_an_expression(action):
     if isinstance(action, six.string_types):
         for name, evaluator in six.iteritems(expressions.get_evaluators()):
             if evaluator.has_expressions(action):
                 return True
Exemple #3
0
 def is_action_an_expression(action):
     if isinstance(action, six.string_types):
         for name, evaluator in six.iteritems(expressions.get_evaluators()):
             if evaluator.has_expressions(action):
                 return True