Wrap an existing initialize function by thawing self for the duration
    of the init.

    Parameters
    ----------
    init : callable
        The user-provided init.

    Returns
    -------
    wrapped : callable
        The wrapped init method.
772157
def _wrapinit(init):
    
    try:
        spec = getfullargspec(init)
    except TypeError:
        # we cannot preserve the type signature.
        def __init__(*args, **kwargs):
            self = args[0]
            __setattr__._initializing.add(self)
            init(*args, **kwargs)
            __setattr__._initializing.remove(self)
            _check_missing_slots(self)

        return __init__

    args = spec.args
    varargs = spec.varargs
    if not (args or varargs):
        raise TypeError(
            "%r must accept at least one positional argument for 'self'" %
            getattr(init, '__qualname__', getattr(init, '__name__', init)),
        )

    if not args:
        self = '%s[0]' % varargs
        forward = argspec = '*' + varargs
    else:
        self = args[0]
        forward = argspec = ', '.join(args)

    if args and varargs:
        forward = '%s, *%s' % (forward, spec.varargs)
        argspec = '%s, *%s' % (argspec, spec.varargs)
    if spec.kwonlyargs:
        forward = '%s, %s' % (
            forward,
            ', '.join(map('{0}={0}'.format, spec.kwonlyargs))
        )
        argspec = '%s,%s%s' % (
            argspec,
            '*, ' if not spec.varargs else '',
            ', '.join(spec.kwonlyargs),
        )
    if spec.varkw:
        forward = '%s, **%s' % (forward, spec.varkw)
        argspec = '%s, **%s' % (argspec, spec.varkw)

    ns = {
        '__init': init,
        '__initializing': __setattr__._initializing,
        '__check_missing_slots': _check_missing_slots,
    }
    exec(
        dedent(
            """\
            def __init__({argspec}):
                __initializing.add({self})
                __init({forward})
                __initializing.remove({self})
                __check_missing_slots({self})
            """.format(
                argspec=argspec,
                self=self,
                forward=forward,
            ),
        ),
        ns,
    )
    __init__ = ns['__init__']
    __init__.__defaults__ = spec.defaults
    __init__.__kwdefaults__ = spec.kwonlydefaults
    __init__.__annotations__ = spec.annotations
    return __init__
869168
def initialize(self):
    

    # Retrieve the necessary extra arguments that were handled automatically
    autoArgs = {name: getattr(self, name) for name in self._poolerArgNames}
    autoArgs["inputDimensions"] = [self._inputWidth]
    autoArgs["columnDimensions"] = [self._columnCount]
    autoArgs["potentialRadius"] = self._inputWidth
    autoArgs["historyLength"] = self._historyLength
    autoArgs["minHistory"] = self._minHistory

    # Allocate the pooler
    self._pooler = self._poolerClass(**autoArgs)
685761
function initAppHandlers (cfg = {}) {
	_.each(handlers, (handler, name) => App[name] = _.partial(handler, _, (_.isFunction(cfg[name])) ? cfg[name] : _.noop));
}
738024
def __initialize_instance(self):
        
        config = self.config

        # Initialize instance of the Authentication class
        self.instance.auth = self.authentication_class(self.app, config=config)

        init_handlers = (
            handlers if config.auth_mode() else auth_mode_agnostic_handlers
        )

        for handler in init_handlers:
            if handler.keys is None:
                self.__check_method_in_auth(handler.name, handler.exception)
            else:
                if all(map(config.get, handler.keys)):
                    self.__check_method_in_auth(
                        handler.name, handler.exception
                    )

        for handler in init_handlers:
            if handler.name in self.kwargs:
                method = self.kwargs.pop(handler.name)
                setattr(self.instance.auth, handler.name, method)
945255
def init_app(cls, app, callback=None):
        
        processed = set()
        cls.__views__ = set()
        cls.is_always_available = False
        for base in cls.__mro__:
            for name, attr in base.__dict__.items():
                if name in processed:
                    continue
                processed.add(name)
                if isinstance(attr, ViewHandler):
                    if base != cls:  # Copy ViewHandler instances into subclasses
                        # TODO: Don't do this during init_app. Use a metaclass
                        # and do this when the class is defined.
                        attr = attr.copy_for_subclass()
                        setattr(cls, name, attr)
                    attr.__set_name__(cls, name)  # Required for Python < 3.6
                    cls.__views__.add(name)
                    attr.init_app(app, cls, callback=callback)
                    if not hasattr(attr.wrapped_func, 'is_available'):
                        cls.is_always_available = True
804111
def _init():
    
    # If there is a context and it is initialized to this request,
    # return, otherwise reinitialize the _local_context.
    if (hasattr(_local_context, '_initialized') and
            _local_context._initialized == os.environ.get('REQUEST_ID_HASH')):
        return

    # Used to track the context object stack.
    _local_context.registry = []

    # Used to provide easy access to the currently running Async job.
    _local_context._executing_async_context = None
    _local_context._executing_async = []

    # So that we do not inadvertently reinitialize the local context.
    _local_context._initialized = os.environ.get('REQUEST_ID_HASH')

    return _local_context
156640
def immutable(function):
    ''''''

    def wrapper(self, *args, **kwargs):
        state = freeze(self._get_state())
        return function(self, state, *args, **kwargs)

    return wrapper
751813
def initialize(self, value=()):
        
        if value == ():
            try:
                return self.default()
            except TypeError:
                return self.default
        else:
            return self.clean(value)
723695
def _loader(app, init_func, entry_points=None, modules=None):
    
    if entry_points:
        for entry_point in entry_points:
            for ep in pkg_resources.iter_entry_points(entry_point):
                try:
                    init_func(ep.load())
                except Exception:
                    app.logger.error(
                        'Failed to initialize entry point: {0}'.format(ep))
                    raise
    if modules:
        for m in modules:
            try:
                init_func(m)
            except Exception:
                app.logger.error('Failed to initialize module: {0}'.format(m))
                raise
1073508
function JQueryWrapper() {
// public
    /**
     * The wrapper is an object, so it can't act like a function. We supply
     * an explicit init() method to be used where jQuery() previously applied.
     */
    this.init = function(selector, context) {
        return new this.jQuery.fn.init(selector, context);
    };

    this.clean = function(elems, context, fragment) {
        return this.jQuery.clean(elems, context, fragment);
    };
}
605526
def initialize(self, init_value, context=None, force=False):
        

        if not force and self._instance is not None:
            raise ConfigurationAlreadyInitializedError(
                'Configuration manager object is already initialized.'
            )

        self.__class__._instance = Root(init_value, context=context)
262560
function init() {
			/* jshint validthis: true */
			// All construction is actually done in the init method.
			if (!initializing) {
				//!steal-remove-start
				if(process.env.NODE_ENV !== 'production') {
					if(!this || (this.constructor !== Constructor) &&
					// We are being called without `new` or we are extending.
					arguments.length && Constructor.constructorExtends) {
						dev.warn('can/construct/construct.js: extending a Construct without calling extend');
					}
				}
				//!steal-remove-end

				return (!this || this.constructor !== Constructor) &&
				// We are being called without `new` or we are extending.
				arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) :
				// We are being called with `new`.
				Constructor.newInstance.apply(Constructor, arguments);
			}
		}
531999
def patch_constructor(model):
    
    old_init = model.__init__

    def new_init(self, *args, **kwargs):
        self._mt_init = True
        populate_translation_fields(self.__class__, kwargs)
        for key, val in list(kwargs.items()):
            new_key = rewrite_lookup_key(model, key)
            # Old key is intentionally left in case old_init wants to play with it
            kwargs.setdefault(new_key, val)
        old_init(self, *args, **kwargs)
    model.__init__ = new_init
1294233
def wraps(self, f):
        
        @_utils.wraps(f)
        def wrapped_f(*args, **kw):
            return self.call(f, *args, **kw)

        def retry_with(*args, **kwargs):
            return self.copy(*args, **kwargs).wraps(f)

        wrapped_f.retry = self
        wrapped_f.retry_with = retry_with

        return wrapped_f
730962
def init_process(self) -> None:
        
        default_loop = asyncio.get_event_loop()
        if default_loop.is_running():
            default_loop.close()
            self.loop = asyncio.new_event_loop()
            asyncio.set_event_loop(self.loop)
        else:
            self.loop = default_loop
        super().init_process()
1123239
def __finish_initializing(self):
        

        if self.args.debug or self.args.trace:
            # Set the console (StreamHandler) to allow debug statements.

            if self.args.debug:
                self.console.setLevel(logging.DEBUG)

            self.console.setFormatter(logging.Formatter('[%(levelname)s] %(asctime)s %(name)s - %(message)s'))

            # Set the global level to debug.
            if self.args.debug:
                self.log.setLevel(logging.DEBUG)

        if self.args.log or self.log_file:

            # Allow the user to override the default log file handler.
            try:
                self.log_file_handler = sys.modules['__main__'].log_file_handler(self.args.log or self.log_file)
            except Exception:
                self.log_file_handler = logging.FileHandler(self.args.log or self.log_file)

            self.log_file_handler.setFormatter(logging.Formatter('[%(levelname)s] %(asctime)s %(name)s - %(message)s'))
            self.log_file_handler.setLevel(logging.DEBUG)

            self.log.addHandler(self.log_file_handler)

        # Allow cli.log, args & self to be accessed from __main__
        if not hasattr(sys.modules['__main__'], 'log'):
            sys.modules['__main__'].log = self.log

        if not hasattr(sys.modules['__main__'], 'cli'):
            sys.modules['__main__'].cli = self

        if not hasattr(sys.modules['__main__'], 'args'):
            sys.modules['__main__'].args = self.args
348181
def pre_init():
    

    logger.info("Run pre-initiation hook of {} plugin.".format(__file__.split(os.path.sep)[-2]))

    # Example: Monkey-Path rafcon.core.script.Script class to print additional log-message while execution
    from rafcon.core.script import Script
    old_execute_method = Script.execute

    def new_execute_method(self, state, inputs=None, outputs=None, backward_execution=False):
        logger.debug("patched version of Script class is used.")
        result = old_execute_method(self, state, inputs, outputs, backward_execution)
        logger.debug("patched version of Script execute-method is finished with result: {}.".format(result))
        return result

    Script.execute = new_execute_method