This decorator ensure that an instance of the
          Evtx class is used within a context statement.  That is,
          that the `with` statement is used, or `__enter__()`
          and `__exit__()` are called explicitly.
425032
def ensure_contexted(func):
        
        @wraps(func)
        def wrapped(self, *args, **kwargs):
            if self._buf is None:
                raise TypeError("An Evtx object must be used with"
                                " a context (see the `with` statement).")
            else:
                return func(self, *args, **kwargs)
        return wrapped
936716
def callwith(context_manager):
    
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwds):
            with context_manager:
                return func(*args, **kwds)
        return wrapper
    return decorator
351172
def onWith(self, evnt, func):
        '''
        
        '''
        self.on(evnt, func)
        # Allow exceptions to propagate during the context manager
        # but ensure we cleanup our temporary callback
        try:
            yield self
        finally:
            self.off(evnt, func)
418728
def wrap_context(func):
    
    @functools.wraps(func)
    def wrapper(self, request, context):
        return func(self, request, LogFieldsContext(context))

    return wrapper
265510
def context(self, line):
        
        # XXX due to a limitation in Visitor,
        # non-python code after the last python code
        # in a file is not added to self.lines, so we
        # have to guard against IndexErrors.
        idx = line - 1
        if idx >= len(self.lines):
            return self.prefix
        return self.lines[idx]
270800
def assert_instance_created(self, model_class, **kwargs):
        
        return _InstanceContext(
            self.assert_instance_does_not_exist,
            self.assert_instance_exists,
            model_class,
            **kwargs
        )
787035
def calledWithMatch(cls, spy, *args, **kwargs): #pylint: disable=invalid-name
        
        cls.__is_spy(spy)
        if not (spy.calledWithMatch(*args, **kwargs)):
            raise cls.failException(cls.message)
790754
def call(__self, __obj, *args, **kwargs):
        
        if __debug__:
            __traceback_hide__ = True
        if isinstance(__obj, _context_function_types):
            if getattr(__obj, 'contextfunction', 0):
                args = (__self,) + args
            elif getattr(__obj, 'evalcontextfunction', 0):
                args = (__self.eval_ctx,) + args
            elif getattr(__obj, 'environmentfunction', 0):
                args = (__self.environment,) + args
        return __obj(*args, **kwargs)
1275986
def func_on_enter(func):
    
    def function_after_enter_pressed(ev):
        ev.stopPropagation()

        # if the key was `enter` ..
        if ev.keyCode == 13:
            func(ev)

    return function_after_enter_pressed
258753
def p_statement_call(p):
    
    if len(p) > 2 and p[2] is None:
        p[0] = None
    elif len(p) == 2:
        entry = SYMBOL_TABLE.get_entry(p[1])
        if not entry or entry.class_ in (CLASS.label, CLASS.unknown):
            p[0] = make_label(p[1], p.lineno(1))
        else:
            p[0] = make_sub_call(p[1], p.lineno(1), make_arg_list(None))
    else:
        p[0] = make_sub_call(p[1], p.lineno(1), p[2])
136291
function exitHook (context, func) {
	if (!func) {
		func = context;
		context = func;
	}

	if (typeof func === 'function') {
		subs.push([func, context])
	}

	return exitHook;
}
798488
def process_def(exp, parent)
      inside_new_context(current_context.method_context_class, exp, parent) do
        increase_statement_count_by(exp.body)
        process(exp)
      end
    end
638615
function(_context) {
        if(this.is_object(_context)) {
          return _context;
        } else {
          var iterator = ".";
          if(this.pragmas["IMPLICIT-ITERATOR"]) {
            iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
          }
          var ctx = {};
          ctx[iterator] = _context;
          return ctx;
        }
      }
952150
def wrap_with(wrapper_cls):
    
    def wrapper(func):
        annotate(func, 'wrapper', [{'wrapper': wrapper_cls}])
        return activate(func)
    return wrapper
1139272
private static boolean isCallToFail(StatementTree then, VisitorState state) {
    while (then.getKind() == BLOCK) {
      List<? extends StatementTree> statements = ((BlockTree) then).getStatements();
      if (statements.size() != 1) {
        return false;
      }
      then = getOnlyElement(statements);
    }
    if (then.getKind() != EXPRESSION_STATEMENT) {
      return false;
    }
    ExpressionTree thenExpr = ((ExpressionStatementTree) then).getExpression();
    if (thenExpr.getKind() != METHOD_INVOCATION) {
      return false;
    }
    MethodInvocationTree thenCall = (MethodInvocationTree) thenExpr;
    ExpressionTree methodSelect = thenCall.getMethodSelect();
    if (methodSelect.getKind() != IDENTIFIER) {
      return false;
      // TODO(cpovirk): Handle "this.fail(...)," etc.
    }
    // TODO(cpovirk): Support *all* fail methods.
    return LEGACY_FAIL_METHOD.matches(methodSelect, state);
  }
997166
def pass_context(f):
    
    def new_func(*args, **kwargs):
        return f(get_current_context(), *args, **kwargs)
    return update_wrapper(new_func, f)
897763
def activate(ctx):
        """"""
        if hasattr(ctx, '_on_context_exit'):
            raise ContextError(
                'Context actions registered outside this '
                'parse context are active')

        try:
            ParseContext._active.append(ctx)
            ctx._on_context_exit = []
            yield
        finally:
            for func, args, kwargs in ctx._on_context_exit:
                func(*args, **kwargs)
            del ctx._on_context_exit
            ParseContext._active.pop()