Decorator for VISA library classes.
336413
def return_handler(module_logger, first_is_session=True):
    

    def _outer(visa_library_method):

        def _inner(self, session, *args, **kwargs):

            ret_value = visa_library_method(*args, **kwargs)
            module_logger.debug('%s%s -> %r',
                                visa_library_method.__name__,
                                _args_to_str(args, kwargs),
                                ret_value)

            try:
                ret_value = constants.StatusCode(ret_value)
            except ValueError:
                pass

            if first_is_session:
                self._last_status = ret_value
                self._last_status_in_session[session] = ret_value

            if ret_value < 0:
                raise VisaIOError(ret_value)

            if ret_value in self.issue_warning_on:
                if session and ret_value not in self._ignore_warning_in_session[session]:
                    module_logger.warn(VisaIOWarning(ret_value), stacklevel=2)

            return ret_value

        return _inner

    return _outer
589930
def delegate(attribute_name, method_names):
    """"""
    # hack for python 2.7 as nonlocal is not available
    info = {
        'attribute': attribute_name,
        'methods': method_names
    }

    def decorator(cls):
        """Decorate class."""
        attribute = info['attribute']
        if attribute.startswith("__"):
            attribute = "_" + cls.__name__ + attribute
        for name in info['methods']:
            setattr(cls, name, eval("lambda self, *a, **kw: "
                                    "self.{0}.{1}(*a, **kw)".format(attribute, name)))
        return cls
    return decorator
490812
def lazy(decorator):
    """"""
    def decorate(fn, *args, **kwargs):
        name = fn.__name__
        parent = decorator(fn, *args, **kwargs)
        #doc = _add_msg(getattr(parent, '__doc__', None), '*@lazy*')
        doc = getattr(parent, '__doc__', None)
        if hasattr(parent, '__set__') or hasattr(parent, '__delete__'):
            return _lazy_data(name, parent, doc)
        else:
            return _lazy_nondata(name, parent, doc)
    return decorate
604434
def decorate_method(cls, func):
        
        func_args = [arg for arg in function_arguments(func) if arg != 'self']
        method_return_types = \
            Endpoint._parse_function_return_types_from_doc(func.__doc__)
        name = '%s.%s' % (cls.path, func.__name__)

        @wraps(func)
        def method_decorator(self, *args, **kwargs):
            for i in range(len(args)):
                kwargs[func_args[i]] = args[i]

            api_call = self.connection._pre_process_call(
                name, endpoint_params=kwargs)
            try:
                data = func(**kwargs)
            except RestException as e:
                api_call.error = e
                raise e

            except Exception as e:
                call_queue = self.connection._call_queue.get(
                    self.connection._get_thread_id(), [])
                if api_call in call_queue:
                    call_queue.remove(api_call)
                e = RestException(original_error=e,
                                  stack=traceback.format_exc())
                log.error('ApiCall Exception: %s' % e, exc_info=True)
                raise e
            return self.connection._post_process_call(
                api_call, data, method_return_types)

        method_decorator.rest_method = True
        return method_decorator
59627
def create_text_object_decorator(registry):
    
    assert isinstance(registry, BaseRegistry)

    operator_given = ViWaitingForTextObjectMode()
    navigation_mode = ViNavigationMode()
    selection_mode = ViSelectionMode()

    def text_object_decorator(*keys, **kw):
        """
        Register a text object function.

        Usage::

            @text_object('w', filter=..., no_move_handler=False)
            def handler(event):
                # Return a text object for this key.
                return TextObject(...)

        :param no_move_handler: Disable the move handler in navigation mode.
            (It's still active in selection mode.)
        """
        filter = kw.pop('filter', Always())
        no_move_handler = kw.pop('no_move_handler', False)
        no_selection_handler = kw.pop('no_selection_handler', False)
        eager = kw.pop('eager', False)
        assert not kw

        def decorator(text_object_func):
            assert callable(text_object_func)

            @registry.add_binding(*keys, filter=operator_given & filter, eager=eager)
            def _(event):
                # Arguments are multiplied.
                vi_state = event.cli.vi_state
                event._arg = (vi_state.operator_arg or 1) * (event.arg or 1)

                # Call the text object handler.
                text_obj = text_object_func(event)
                if text_obj is not None:
                    assert isinstance(text_obj, TextObject)

                    # Call the operator function with the text object.
                    vi_state.operator_func(event, text_obj)

                # Clear operator.
                event.cli.vi_state.operator_func = None
                event.cli.vi_state.operator_arg = None

            # Register a move operation. (Doesn't need an operator.)
            if not no_move_handler:
                @registry.add_binding(*keys, filter=~operator_given & filter & navigation_mode, eager=eager)
                def _(event):
                    " Move handler for navigation mode. "
                    text_object = text_object_func(event)
                    event.current_buffer.cursor_position += text_object.start

            # Register a move selection operation.
            if not no_selection_handler:
                @registry.add_binding(*keys, filter=~operator_given & filter & selection_mode, eager=eager)
                def _(event):
                    " Move handler for selection mode. "
                    text_object = text_object_func(event)
                    buff = event.current_buffer

                    # When the text object has both a start and end position, like 'i(' or 'iw',
                    # Turn this into a selection, otherwise the cursor.
                    if text_object.end:
                        # Take selection positions from text object.
                        start, end = text_object.operator_range(buff.document)
                        start += buff.cursor_position
                        end += buff.cursor_position

                        buff.selection_state.original_cursor_position = start
                        buff.cursor_position = end

                        # Take selection type from text object.
                        if text_object.type == TextObjectType.LINEWISE:
                            buff.selection_state.type = SelectionType.LINES
                        else:
                            buff.selection_state.type = SelectionType.CHARACTERS
                    else:
                        event.current_buffer.cursor_position += text_object.start

            # Make it possible to chain @text_object decorators.
            return text_object_func

        return decorator
    return text_object_decorator
293842
def wraps(wrapped):
    """"""
    if isinstance(wrapped, functools.partial):
        return six.wraps(wrapped, assigned=_PARTIAL_VALID_ASSIGNMENTS)
    else:
        return six.wraps(wrapped)
925735
def _apply_decorators(func, decorators):
    
    decorators = filter(_is_not_none_or_false, reversed(decorators))

    for decorator in decorators:
        func = decorator(func)

    return func
217492
def decorator(func):
  
  """
  def wrapper(__decorated__=None, *Args, **KwArgs):
    if __decorated__ is None: # the decorator has some optional arguments.
      return lambda _func: func(_func, *Args, **KwArgs)

    else:
      return func(__decorated__, *Args, **KwArgs)

  return wrap(wrapper, func)
814680
function coolors(msg, config){
    if(supportsColor) {
        switch (typeof config) {
            case 'string':
                    if(plugins[config]){
                        msg = plugins[config](msg);
                    }
                break;
            case 'object':
                var decorators = Object.keys(styles.decorators);
                decorators.forEach(function (decorator) {
                    if (config[decorator]) {
                        msg = styles.decorators[decorator](msg);
                    }
                });
                ['text', 'background'].forEach(function (option) {
                    if (config[option] && styles[option][config[option]]) {
                        msg = styles[option][config[option]](msg);
                    }
                });
                break;
        }
    }
    return msg;
}
80825
def _wrapper(func, *vect_args, **vect_kwargs):
        """"""
        if not hasattr(func, '__name__'):
            # Set name if not available. Happens if func is actually a function
            func.__name__ = '{}.__call__'.format(func.__class__.__name__)

        return wraps(func)(_NumpyVectorizeWrapper(func, *vect_args,
                                                  **vect_kwargs))
194543
function Lisp (input, lib, tables, host) {
  const Context = function (scope, parent) {
    this.scope = scope
    this.parent = parent

    this.get = function (identifier) {
      if (identifier in this.scope) {
        return this.scope[identifier]
      } else if (this.parent !== undefined) {
        return this.parent.get(identifier)
      }
    }
  }

  const special = {
    let: function (input, context) {
      const letContext = input[1].reduce(function (acc, x) {
        acc.scope[x[0].value] = interpret(x[1], context)
        return acc
      }, new Context({}, context))

      return interpret(input[2], letContext)
    },

    lambda: function (input, context) {
      return function () {
        const lambdaArguments = arguments
        const lambdaScope = input[1].reduce(function (acc, x, i) {
          acc[x.value] = lambdaArguments[i]
          return acc
        }, {})

        return interpret(input[2], new Context(lambdaScope, context))
      }
    }
  }

  const interpretList = function (input, context) {
    if (input.length > 0 && input[0].value in special) {
      return special[input[0].value](input, context)
    }
    const list = input.map(function (x) { return interpret(x, context) })
    return list[0] instanceof Function ? list[0].apply(undefined, list.slice(1)) : list
  }

  const interpret = function (input, context) {
    if (context === undefined) {
      return interpret(input, new Context(lib))
    } else if (input instanceof Array) {
      return interpretList(input, context)
    } else if (input.type === 'identifier') {
      return context.get(input.value)
    } else if (input.type === 'keyword') {
      return host[input.value] ? host[input.value] : null
    } else if (input.type === 'number' || input.type === 'string' || input.type === 'bool') {
      return input.value
    }
  }

  const categorize = function (input) {
    if (!isNaN(parseFloat(input))) {
      return { type: 'number', value: parseFloat(input) }
    } else if (input[0] === '"' && input.slice(-1) === '"') {
      return { type: 'string', value: input.slice(1, -1) }
    } else if (input[0] === ':') {
      return { type: 'keyword', value: input.substr(1, input.length - 1) }
    } else if (input === 'true' || input === 'false') {
      return { type: 'bool', value: input === 'true' }
    } else {
      return { type: 'identifier', value: input }
    }
  }

  const parenthesize = function (input, list) {
    if (list === undefined) { return parenthesize(input, []) }

    const token = input.shift()

    if (token === undefined) {
      return list.pop()
    } else if (token === '(') {
      list.push(parenthesize(input, []))
      return parenthesize(input, list)
    } else if (token === ')') {
      return list
    } else {
      return parenthesize(input, list.concat(categorize(token)))
    }
  }

  const tokenize = function (input) {
    return input.split('"').map(function (x, i) { return i % 2 === 0 ? x.replace(/\(/g, ' ( ').replace(/\)/g, ' ) ') : x.replace(/ /g, '!whitespace!') }).join('"').trim().split(/\s+/).map(function (x) { return x.replace(/!whitespace!/g, ' ') })
  }

  this.parse = function (input) {
    return parenthesize(tokenize(input))
  }

  this.toString = function () {
    return `${interpret(this.parse(input))}`
  }
}
1361054
def with_lock(lock):
  """"""
  def decorator(func):
    @functools.wraps(func)
    def _with_lock(*args, **kwargs):
      with lock:
        return func(*args, **kwargs)
    return _with_lock
  return decorator
281836
def choice(choices):
    """"""
    def decorator(function):
        """Decorate a function with args."""
        @functools.wraps(function)
        def wrapper(*args, **kwargs):
            """Wrap the function."""
            series = function(*args, **kwargs)
            return series.isin(set(choices))

        return wrapper

    return decorator
129035
def define(self, klass, name="default"):
        

        def decorate(func):
            @wraps(func)
            def wrapped(*args, **kwargs):
                return func(*args, **kwargs)

            self.register(klass, func, name=name)

            return wrapped

        return decorate
86937
def __insert_wrapper(func):
        """"""
        def check_func(self, key, new_item, instance=0):
            if key not in self.keys():
                raise KeyError("%s not a key in label" % (key))
            if not isinstance(new_item, (list, OrderedMultiDict)):
                raise TypeError("The new item must be a list or PVLModule")
            if isinstance(new_item, OrderedMultiDict):
                new_item = list(new_item)
            return func(self, key, new_item, instance)
        return check_func
889602
def bootstrap_styled(cls=None, add_meta=True, form_group=True, 
    input_class='form-control'):
    

    def real_decorator(cls):
        class NewClass(cls): pass
        NewClass.__name__ = cls.__name__
        NewClass = custom_widget_wrapper(NewClass)

        _call = NewClass.__call__

        def call(*args, **kwargs):
            if input_class:
                kwargs.setdefault('class', input_class)

            return _call(*args, **kwargs)

        if add_meta: call = meta_wrapped(call)
        if form_group: call = form_group_wrapped(call)

        NewClass.__call__ = call
        return NewClass

    if cls:
        # Allow calling decorator(cls) instead of decorator()(cls)
        rv = real_decorator(cls)
        return rv

    return real_decorator
447092
def wraps(
    wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, updated=functools.WRAPPER_UPDATES
):
    """"""
    if not is_cython_function(wrapped):
        return functools.wraps(wrapped, assigned, updated)
    else:
        return lambda wrapper: wrapper