Decorate services
961626
public function beforeCompile(): void
	{
		$builder = $this->getContainerBuilder();

		// Register console helper only if console is provided
		$application = $builder->getByType(Application::class, false);

		if ($application !== null) {
			$applicationDef = $builder->getDefinition($application);
			$applicationDef->addSetup(
				new Statement('$service->getHelperSet()->set(?)', [$this->prefix('@configurationHelper')])
			);
		}
	}
191405
def pass_service(*names):
    
    def decorator(f):
        @functools.wraps(f)
        def wrapper(*args, **kwargs):
            for name in names:
                kwargs[name] = service_proxy(name)
            return f(*args, **kwargs)
        return wrapper
    return decorator
162175
private function init_theme_providers()
    {
        foreach (Config::get('services.theme_providers') as $class_name) {
            if (\is_subclass_of($class_name, \Snap\Services\Service_Provider::class)) {
                $provider = Container::resolve($class_name);
                Container::resolve_method($provider, 'register');
                return;
            }
        }
    }
735738
function decorate(engine) {
  // save a reference to original methods
  var renderSync = engine.renderSync;
  var render = engine.render;
  var compile = engine.compile;

  /**
   * Wrapped compile function for all engines loaded onto engine-cache.
   * If possible, compiles the string with the original engine's compile function.
   * Returns a render function that will either use the original engine's compiled function
   * or the `render/renderSync` methods and will resolve async helper ids.
   *
   * ```js
   * var fn = engine.compile('<%= upper(foo) %>', {imports: {'upper': upper}});
   * fn({foo: 'bar'}));
   * //=> BAR
   * ```
   *
   * @param  {String} `str` Original string to compile.
   * @param  {Object} `opts` Options/options to pass to engine's compile function. If a function is passed on `options.mergeFn`, that will be used for merging context before passing it to render.
   * @return {Function} Returns render function to call that takes `locals` and optional `callback` function.
   */

  engine.compile = function engineCompile(str, options) {
    if (typeof str === 'function') {
      return str;
    }

    if (typeof options !== 'undefined' && !isObject(options)) {
      throw new TypeError('expected options to be an object or undefined');
    }

    options = extend({}, options);
    var helpers = mergeHelpers(engine, options);
    var compiled = compile ? compile.call(engine, str, helpers) : null;

    return function(locals, cb) {
      if (typeof locals === 'function') {
        cb = locals;
        locals = {};
      }

      // if compiled already, we can delete helpers and partials from
      // the `helpers` object, since were bound to the context and
      // passed to the engine at compile time
      if (typeof compiled === 'function') {
        str = compiled;
        helpers = {};
      }

      var data = {};
      if (typeof locals === 'string' || Array.isArray(locals)) {
        data = locals;

      } else if (options && typeof options.mergeFn === 'function') {
        data = options.mergeFn(helpers, locals);

      } else {
        data = merge({}, locals, helpers);
      }

      if (typeof cb !== 'function') {
        return renderSync.call(engine, str, data);
      }

      render.call(engine, str, data, function(err, str) {
        if (err) {
          cb(err);
          return;
        }
        engine.asyncHelpers.resolveIds(str, cb);
      });
    };
  };

  /**
   * Wrapped render function for all engines loaded onto engine-cache.
   * Compiles and renders strings with given context.
   *
   * ```js
   *  engine.render('<%= foo %>', {foo: 'bar'}, function(err, content) {
   *    //=> bar
   *  });
   * ```
   *
   * @param  {String|Function} `str` Original string to compile or function to use to render.
   * @param  {Object} `options` Options/locals to pass to compiled function for rendering.
   * @param {Function} `cb` Callback function that returns `err, content`.
   */

  engine.render = function engineRender(str, locals, cb) {
    if (typeof locals === 'function') {
      cb = locals;
      locals = {};
    }

    if (typeof cb !== 'function') {
      throw new TypeError('expected a callback function');
    }

    if (typeof str === 'function') {
      var fn = str;
      fn(locals, cb);
      return;
    }

    if (typeof str !== 'string') {
      cb(new TypeError('expected a string or compiled function'));
      return;
    }

    var async = locals.async;
    locals.async = true;

    // compile the template to create a function
    var render = this.compile(str, locals);

    // call the function to render templates
    render(locals, function(err, content) {
      if (err) {
        cb(err);
        return;
      }
      // reset original `async` value
      locals.async = async;
      cb(null, content);
    });
  };

  /**
   * Wrapped renderSync function for all engines loaded onto engine-cache.
   * Compiles and renders strings with given context.
   *
   * ```js
   * engine.renderSync('<%= foo %>', {foo: 'bar'});
   * //=> bar
   * ```
   *
   * @param  {String|Function} `str` Original string to compile or function to use to render.
   * @param  {Object} `locals` Locals or options to pass to compiled function for rendering.
   * @return {String} Returns rendered content.
   */

  engine.renderSync = function wrappedRenderSync(str, locals) {
    if (typeof str === 'function') {
      return str(locals);
    }

    if (typeof str !== 'string') {
      throw new TypeError('expected a string or compiled function');
    }

    var context = extend({}, locals);
    context.helpers = merge({}, this.helpers, context.helpers);
    return this.compile(str, context)(context);
  };
}
231250
def _start_services(self, console_env):
        """"""
        self._ad.services.register('sl4a', sl4a_service.Sl4aService)
        console_env['s'] = self._ad.services.sl4a
        console_env['sl4a'] = self._ad.sl4a
        console_env['ed'] = self._ad.ed
582088
def register_service(self, service):
        
        if service not in self.services:
            self.services.append(service)
922420
def _decorate(self, atype, n, o):
        
        typemap = {"function": "functions",
                   "classobj": "classes",
                   "staticmethod": "methods",
                   "type": "classes"}
        from acorn.logging.decoration import decorate_obj
        try:
            otype = typemap[atype]
            decorate_obj(self.shell.user_ns, n, o, otype)
            #Also create a log in the database for this execution; this allows a
            #user to track the changes they make in prototyping function and
            #class definitions.
            self._logdef(n, o, otype)
            msg.okay("Auto-decorated {}: {}.".format(n, o))
        except:
            msg.err("Error auto-decorating {}: {}.".format(n, o))
            raise
1374655
def decorate(self, func, limit, ttl, *anoop, **kwnoop):
        """"""
        return super(ratelimit, self).decorate(func, limit, ttl, *anoop, **kwnoop)
1200527
function decorate(type, name, combinator, ...terms) {
  /* istanbul ignore else */
  if (__DEV__) terms = freeze(terms);

  defineProperties(type, {
    [TYPICAL_TYPE]: { configurable, enumerable, value: true },
    name: { configurable, value: name },
    kind: { configurable, value: combinator.name },
    is: { configurable, value: v => type(v, { asPredicate: true }) },
    combinator: { configurable, value: combinator },
    terms: { configurable, value: terms },
    toString: {
      configurable,
      value() {
        return `[typical-${combinator.name}-type ${this.name}]`;
      },
    },
  });

  return type;
}
1239300
def decorate(templates, path_info, details, locals)
      templates.each do |t|
        t.locals = locals
      end
    end
163849
def create(self):
        
        self.add_handlers({'^T': self.quit, '^Q': self.quit})
        self.services_tft = self.add(npyscreen.TitleFixedText,
                                     name='No services running.',
                                     value='')
        services = Services(self.core, external=self.external)
        if services:
            self.services_tft.hidden = True
            for service in services:
                value = ''
                for val in service[1]:
                    value += val+', '
                self.add(npyscreen.TitleFixedText,
                         name=service[0],
                         value=value[:-2])
932060
protected function initServices()
    {
        $dependencies = $this->config->get('dependencies', null);
        $this->getDI()->setShared('registrant', new Registrant($dependencies));
        $this->getDI()->setShared('config', $this->config);
        $this->getDI()->get('registrant')->registration();
    }
862542
public function beforeCompile(): void
	{
		$builder = $this->getContainerBuilder();

		// Register as services
		foreach ($builder->findByType(IContainerAware::class) as $service) {
			$service->addSetup('setContainer');
		}
	}
1302261
def decorate(self, app):
		
		from functools import wraps

		@wraps(app)
		def decorated(environ, start_response):
			# capture any start_response from the app
			app_response = {}
			app_response['status'] = "200 OK"
			app_response['headers'] = []
			app_response['written'] = BytesIO()
			def custom_start_response(status, headers, *args, **kwargs):
				app_response['status'] = status
				app_response['headers'] = headers
				app_response['args'] = args
				app_response['kwargs'] = kwargs
				return app_response['written'].write
			returned = app(environ, custom_start_response)

			# callbacks from the serialization
			def set_http_code(status):
				app_response['status'] = str(status)
			def set_header(header, value):
				app_response['headers'] = [(h,v) for (h,v) in app_response['headers'] if h.lower() != header.lower()]
				app_response['headers'].append((header, value))
			def set_content_type(content_type):
				set_header('Content-Type', content_type)

			# do the serialization
			accept = environ.get('HTTP_ACCEPT', '')
			new_return = self.output(returned, accept, set_http_code, set_content_type)

			# set the Vary header
			vary_headers = (v for (h,v) in app_response['headers'] if h.lower() == 'vary')
			vary_elements = list(itertools.chain(*[v.split(',') for v in vary_headers]))
			vary_elements = list(set([v.strip() for v in vary_elements]))
			if '*' not in vary_elements and 'accept' not in (v.lower() for v in vary_elements):
				vary_elements.append('Accept')
				set_header('Vary', ', '.join(vary_elements))

			# pass on the result to the parent WSGI server
			parent_writer = start_response(app_response['status'],
			                               app_response['headers'],
			                               *app_response.get('args', []),
			                               **app_response.get('kwargs', {}))
			written = app_response['written'].getvalue()
			if len(written) > 0:
				parent_writer(written)
			return new_return
		return decorated
798676
public static function setup(): void
    {
        $aComponents          = Components::available();
        self::$aContainers    = [];
        self::$aLoadedHelpers = [];
        $aDiscoveredServices  = [
            'nails/common' => self::findServicesForComponent('nails/common'),
        ];

        foreach ($aComponents as $oComponent) {
            $aDiscoveredServices[$oComponent->slug] = self::findServicesForComponent($oComponent->slug);
        }

        $aDiscoveredServices['app'] = self::findServicesForApp();
        $aDiscoveredServices        = array_filter($aDiscoveredServices);

        foreach ($aDiscoveredServices as $sComponentName => $aComponentServices) {

            //  Properties
            if (!empty($aComponentServices['properties'])) {
                if (empty(self::$aContainers[$sComponentName]['properties'])) {
                    self::$aContainers[$sComponentName]['properties'] = new Container();
                }
                foreach ($aComponentServices['properties'] as $sKey => $mValue) {
                    self::$aContainers[$sComponentName]['properties'][$sKey] = $mValue;
                }
            }

            // --------------------------------------------------------------------------

            /**
             * SERVICES
             * All services are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['services'])) {
                if (empty(self::$aContainers[$sComponentName]['services'])) {
                    self::$aContainers[$sComponentName]['services'] = new Container();
                }
                foreach ($aComponentServices['services'] as $sKey => $cCallable) {
                    self::$aContainers[$sComponentName]['services'][$sKey] = function () use ($sKey, $cCallable) {
                        return $cCallable;
                    };;
                }
            }

            // --------------------------------------------------------------------------

            /**
             * MODELS
             * All models are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['models'])) {
                if (empty(self::$aContainers[$sComponentName]['models'])) {
                    self::$aContainers[$sComponentName]['models'] = new Container();
                }
                foreach ($aComponentServices['models'] as $sKey => $cCallable) {
                    self::$aContainers[$sComponentName]['models'][$sKey] = function () use ($cCallable) {
                        return $cCallable;
                    };
                }
            }

            // --------------------------------------------------------------------------

            /**
             * FACTORIES
             * All factories are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['factories'])) {
                if (empty(self::$aContainers[$sComponentName]['factories'])) {
                    self::$aContainers[$sComponentName]['factories'] = new Container();
                }
                foreach ($aComponentServices['factories'] as $sKey => $cCallable) {

                    $cWrapper = function () use ($cCallable) {
                        return $cCallable;
                    };

                    self::$aContainers[$sComponentName]['factories'][$sKey] = self::$aContainers[$sComponentName]['factories']
                        ->factory($cWrapper);
                }
            }

            // --------------------------------------------------------------------------

            /**
             * FACTORIES
             * All factories are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['resources'])) {
                if (empty(self::$aContainers[$sComponentName]['resources'])) {
                    self::$aContainers[$sComponentName]['resources'] = new Container();
                }
                foreach ($aComponentServices['resources'] as $sKey => $cCallable) {

                    $cWrapper = function () use ($cCallable) {
                        return $cCallable;
                    };

                    self::$aContainers[$sComponentName]['resources'][$sKey] = self::$aContainers[$sComponentName]['resources']
                        ->factory($cWrapper);
                }
            }
        }
    }
717622
function decorateClients(clients, clientsInfo) {
    return clients.map(function (item) {
        clientsInfo.forEach(function (client) {
            if (client.id === item.id) {
                item.data = client.data;
                return false;
            }
        });
        return item;
    });
}
971986
def _decorate_fun(self, fun):
        """"""

        msg = "Function %s is deprecated" % fun.__name__
        if self.extra:
            msg += "; %s" % self.extra

        def wrapped(*args, **kwargs):
            warnings.warn(msg, category=DeprecationWarning)
            return fun(*args, **kwargs)

        wrapped.__name__ = fun.__name__
        wrapped.__dict__ = fun.__dict__
        wrapped.__doc__ = self._update_doc(fun.__doc__)

        return wrapped