(self, expr, context)
return result
Evaluate a marker expression returned by the :func:`parse_requirement`
        function in the specified context.
Evaluate a marker expression returned by the :func:`parse_requirement`
        function in the specified context.
Evaluate a marker expression returned by the : func : parse_requirement function in the specified context .
def evaluate(self, expr, context):
        """
        Evaluate a marker expression returned by the :func:`parse_requirement`
        function in the specified context.
        """
        if isinstance(expr, string_types):
            if expr[0] in '\'"':
                result = expr[1:-1]
            else:
                if expr not in context:
                    raise SyntaxError('unknown variable: %s' % expr)
                result = context[expr]
        else:
            assert isinstance(expr, dict)
            op = expr['op']
            if op not in self.operations:
                raise NotImplementedError('op not implemented: %s' % op)
            elhs = expr['lhs']
            erhs = expr['rhs']
            if _is_literal(expr['lhs']) and _is_literal(expr['rhs']):
                raise SyntaxError('invalid comparison: %s %s %s' % (elhs, op, erhs))

            lhs = self.evaluate(elhs, context)
            rhs = self.evaluate(erhs, context)
            result = self.operations[op](lhs, rhs)
        return result
def evaluate ( self , expr , context ) : if isinstance ( expr , string_types ) : if expr [ 0 ] in '\'"' : result = expr [ 1 : - 1 ] else : if expr not in context : raise SyntaxError ( 'unknown variable: %s' % expr ) result = context [ expr ] else : assert isinstance ( expr , dict ) op = expr [ 'op' ] if op not in self . operations : raise NotImplementedError ( 'op not implemented: %s' % op ) elhs = expr [ 'lhs' ] erhs = expr [ 'rhs' ] if _is_literal ( expr [ 'lhs' ] ) and _is_literal ( expr [ 'rhs' ] ) : raise SyntaxError ( 'invalid comparison: %s %s %s' % ( elhs , op , erhs ) ) lhs = self . evaluate ( elhs , context ) rhs = self . evaluate ( erhs , context ) result = self . operations [ op ] ( lhs , rhs ) return result