Recursively evaluates a compiled expression using the specified context.
    Dict instances can contain a "__kwargs" key which will be used to update the
    dict with its content
541695
def eval_expr(expr, context):
    
    if isinstance(expr, list):
        rv = []
        for item in expr:
            rv.append(eval_expr(item, context))
        return rv
    if isinstance(expr, dict):
        rv = {}
        for k, v in expr.iteritems():
            rv[k] = eval_expr(v, context)
        kwargs = rv.pop("__kwargs", None)
        if kwargs:
            rv.update(kwargs)
        return rv
    if isinstance(expr, Expression):
        return expr.eval(context)
    return expr
523394
def batch_eval(*args, **kwargs):
  
  # Inside function to avoid circular import
  from cleverhans.evaluation import batch_eval as new_batch_eval
  warnings.warn("batch_eval has moved to cleverhans.evaluation. "
                "batch_eval will be removed from utils_tf on or after "
                "2019-03-09.")
  return new_batch_eval(*args, **kwargs)
913906
Object evaluate(String pExpressionString,
                    Object pContext,
                    Class pExpectedType,
                    Map functions,
                    String defaultPrefix,
                    Logger pLogger)
            throws ELException {
        // Check for null expression strings
        if (pExpressionString == null) {
            throw new ELException
                    (Constants.NULL_EXPRESSION_STRING);
        }

        // Set the PageContext;
        pageContext = (PageContext) pContext;

        // Get the parsed version of the expression string
        Object parsedValue = parseExpressionString(pExpressionString);

        // Evaluate differently based on the parsed type
        if (parsedValue instanceof String) {
            // Convert the String, and cache the conversion
            String strValue = (String) parsedValue;
            return convertStaticValueToExpectedType(strValue,
                    pExpectedType,
                    pLogger);
        } else if (parsedValue instanceof Expression) {
            // Evaluate the expression and convert
            Object value =
                    ((Expression) parsedValue).evaluate(pContext,
                            mResolver,
                            functions,
                            defaultPrefix,
                            pLogger);
            return convertToExpectedType(value,
                    pExpectedType,
                    pLogger);
        } else if (parsedValue instanceof ExpressionString) {
            // Evaluate the expression/string list and convert
            String strValue =
                    ((ExpressionString) parsedValue).evaluate(pContext,
                            mResolver,
                            functions,
                            defaultPrefix,
                            pLogger);
            return convertToExpectedType(strValue,
                    pExpectedType,
                    pLogger);
        } else {
            // This should never be reached
            return null;
        }
    }
600799
def get_compilation_context(instance):
    
    context_builder = SqlaContext(instance.__class__)
    py3o_context = context_builder.compile_obj(instance)
    return py3o_context
484452
def call(self, params, _context, **kwargs):
        ''''''

        assert len(params) == self.paramCount
        # using setattr because '=' is not allowed inside of lambdas
        return evaluate_impl(self.body, params).then(lambda value: setattr(_context.results, 'value', value))
1225693
def get_context(self, arr, expr, context):
        

        expression_names = [x for x in self.get_expression_names(expr) if x not in set(context.keys()).union(['i'])]

        if len(expression_names) != 1:
            raise ValueError('The expression must have exactly one variable.')

        return {expression_names[0]: arr}
926421
def context_cache(func):
    '''
    
    '''
    def context_cache_wrap(*args, **kwargs):
        func_context = func.__globals__['__context__']
        func_opts = func.__globals__['__opts__']
        func_name = func.__globals__['__name__']

        context_cache = ContextCache(func_opts, func_name)
        if not func_context and os.path.isfile(context_cache.cache_path):
            salt.utils.dictupdate.update(func_context, context_cache.get_cache_context())
        else:
            context_cache.cache_context(func_context)
        return func(*args, **kwargs)
    return context_cache_wrap
481971
def attr(**context):
    
    #TODO(Jim Zhan) FIXME
    def decorator(func):
        def wrapped_func(*args, **kwargs):
            for key, value in context.items():
                print key, value
            return func(*args, **kwargs)
        return wraps(func)(decorator)
    return decorator
444636
String buildUpdateExpression(SubstitutionContext context) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, List<UpdateAction>> e: updates.entrySet()) {
            boolean firstOfUpdateType = true;
            for (UpdateAction expr: e.getValue()) {
                if (firstOfUpdateType) {
                    firstOfUpdateType = false;
                    final String operator = e.getKey();
                    if (sb.length() > 0)
                        sb.append(" ");
                    sb.append(operator).append(" ");
                } else {
                    sb.append(", ");
                }
                sb.append(expr.asSubstituted(context));
            }
        }
        return sb.toString();
    }
513258
def eval(self, exp):
    ""
    # todo: this needs an AST-assert that all BaseX descendants are being handled
    if isinstance(exp,sqparse2.BinX): return evalop(exp.op.op, *map(self.eval, (exp.left, exp.right)))
    elif isinstance(exp,sqparse2.UnX): return self.eval_unx(exp)
    elif isinstance(exp,sqparse2.NameX): return self.nix.rowget(self.tables,self.c_row,exp)
    elif isinstance(exp,sqparse2.AsterX): return sum(self.c_row,[]) # todo doc: how does this get disassembled by caller?
    elif isinstance(exp,sqparse2.ArrayLit): return map(self.eval,exp.vals)
    elif isinstance(exp,(sqparse2.Literal,sqparse2.ArrayLit)): return exp.toliteral()
    elif isinstance(exp,sqparse2.CommaX):
      # todo: think about getting rid of CommaX everywhere; it complicates syntax tree navigation.
      #   a lot of things that are CommaX now should become weval.Row.
      ret = []
      for child in exp.children:
        (ret.extend if starlike(child) else ret.append)(self.eval(child))
      return ret
    elif isinstance(exp,sqparse2.CallX): return self.eval_callx(exp)
    elif isinstance(exp,sqparse2.SelectX):
      raise NotImplementedError('subqueries should have been evaluated earlier') # todo: specific error class
    elif isinstance(exp,sqparse2.AttrX):return self.nix.rowget(self.tables,self.c_row,exp)
    elif isinstance(exp,sqparse2.CaseX):
      for case in exp.cases:
        if self.eval(case.when): return self.eval(case.then)
      return self.eval(exp.elsex)
    elif isinstance(exp,sqparse2.CastX):
      if exp.to_type.type.lower() in ('text','varchar'): return unicode(self.eval(exp.expr))
      else: raise NotImplementedError('unhandled_cast_type',exp.to_type)
    elif isinstance(exp,(int,basestring,float,type(None))):
      return exp # I think Table.insert is creating this in expand_row
    # todo: why tuple, list, dict below? throw some asserts in here and see where these are coming from.
    elif isinstance(exp,tuple): return tuple(map(self.eval, exp))
    elif isinstance(exp,list): return map(self.eval, exp)
    elif isinstance(exp,dict): return exp
    elif isinstance(exp,sqparse2.NullX): return None
    elif isinstance(exp,sqparse2.ReturnX):
      # todo: I think ReturnX is *always* CommaX now; revisit this
      ret=self.eval(exp.expr)
      print "warning: not sure what I'm doing here with cardinality tweak on CommaX"
      return [ret] if isinstance(exp.expr,(sqparse2.CommaX,sqparse2.AsterX)) else [[ret]] # todo: update parser so this is always * or a commalist
    elif isinstance(exp,sqparse2.AliasX): return self.eval(exp.name) # todo: rename AliasX 'name' to 'expr'
    else: raise NotImplementedError(type(exp), exp)
1039996
private static List<String> _evaluateValueExpressions(FacesContext context, List<String> values)
    {
        // note that we have to create a new List here, because if we
        // change any value on the given List, it will be changed in the
        // NavigationCase too and the EL expression won't be evaluated again
        List<String> target = new ArrayList<String>(values.size());
        for (String value : values)
        {
            if (_isExpression(value))
            {
                // evaluate the ValueExpression
                value = context.getApplication().evaluateExpressionGet(context, value, String.class);
            }
            target.add(value);
        }
        return target;
    }
1215155
def _parse_index_value(self, kwargs):
        
        if len(kwargs) == 0:
            return None, None
        elif len(kwargs) > 1:
            raise ValueError("You can't pass more than one value expression, "
                             "you passed {}".format(",".join(kwargs.keys())))

        name, value = list(kwargs.items())[0]

        if not name.startswith('value'):
            raise ValueError("The keyword arg {} is not valid for this "
                             "function".format(name))

        if name == 'value':
            return ('=', value)

        if not name.startswith('value__'):
            raise ValueError("The keyword arg {} is not valid for this "
                             "function".format(name))

        operator = name[name.find('__') + 2:]
        try:
            return (self._operator_values[operator], value)
        except KeyError:
            raise ValueError(
                "The operator {op} is not valid for index value matching. "
                "Valid operators are {valid}"
                .format(
                    op=operator,
                    valid=",".join(self._operator_values.keys()),
                ),
            )
1247961
@Nonnull
  public static Value evalTree(@Nonnull final ExpressionTree tree, @Nonnull final PreprocessorContext context) {
    final Expression exp = new Expression(context, tree);
    return exp.eval(context.getPreprocessingState());
  }
49765
def _get_value(context, key):
    
    if isinstance(context, dict):
        # Then we consider the argument a "hash" for the purposes of the spec.
        #
        # We do a membership test to avoid using exceptions for flow control
        # (e.g. catching KeyError).
        if key in context:
            return context[key]
    elif type(context).__module__ != _BUILTIN_MODULE:
        # Then we consider the argument an "object" for the purposes of
        # the spec.
        #
        # The elif test above lets us avoid treating instances of built-in
        # types like integers and strings as objects (cf. issue #81).
        # Instances of user-defined classes on the other hand, for example,
        # are considered objects by the test above.
        try:
            attr = getattr(context, key)
        except AttributeError:
            # TODO: distinguish the case of the attribute not existing from
            #   an AttributeError being raised by the call to the attribute.
            #   See the following issue for implementation ideas:
            #     http://bugs.python.org/issue7559
            pass
        else:
            # TODO: consider using EAFP here instead.
            #   http://docs.python.org/glossary.html#term-eafp
            if callable(attr):
                return attr()
            return attr

    return _NOT_FOUND
827650
def inject_context(self, __context_dict__=None, **context):
        
        context = context or __context_dict__
        self.context_keys |= set(context.keys())
        for key, value in context.items():
            setattr(self, key, value)
        for command in self.subcommands.values():
            command.inject_context(context)
197457
def _update_context_field_expression(present_locations, expression):
    """"""
    no_op_blocks = (ContextField, Literal, LocalField, UnaryTransformation, Variable)
    if isinstance(expression, BinaryComposition):
        if isinstance(expression.left, ContextField) or isinstance(expression.right, ContextField):
            return _update_context_field_binary_composition(present_locations, expression)
        else:
            return _simplify_non_context_field_binary_composition(expression)
    elif isinstance(expression, TernaryConditional):
        return _simplify_ternary_conditional(expression)
    elif isinstance(expression, BetweenClause):
        lower_bound = expression.lower_bound
        upper_bound = expression.upper_bound
        if isinstance(lower_bound, ContextField) or isinstance(upper_bound, ContextField):
            raise AssertionError(u'Found BetweenClause with ContextFields as lower/upper bounds. '
                                 u'This should never happen: {}'.format(expression))
        return expression
    elif isinstance(expression, (OutputContextField, FoldedContextField)):
        raise AssertionError(u'Found unexpected expression of type {}. This should never happen: '
                             u'{}'.format(type(expression).__name__, expression))
    elif isinstance(expression, no_op_blocks):
        return expression

    raise AssertionError(u'Found unhandled expression of type {}. This should never happen: '
                         u'{}'.format(type(expression).__name__, expression))
361667
private final EvalResult doDefine(List<SExpression> subexpressions, Environment environment,
      ParametricBfgBuilder builder, EvalContext context) {
    int nameToBind = subexpressions.get(1).getConstantIndex();
    if (subexpressions.size() == 3) {
      // (define name value-expression)
      // Binds a name to the value of value-expression
      Object valueToBind = eval(subexpressions.get(2), environment, builder, context).getValue();
      environment.bindName(nameToBind, valueToBind);
    } else if (subexpressions.size() >= 4) {
      // (define procedure-name (arg1 ...) procedure-body)
      // syntactic sugar equivalent to (define procedure-name (lambda (arg1 ...) procedure-body
      AmbLambdaValue lambdaValue =  makeLambda(subexpressions.get(2),
          subexpressions.subList(3, subexpressions.size()), environment);
      environment.bindName(nameToBind, lambdaValue);
    }
    return new EvalResult(ConstantValue.UNDEFINED);
  }