Iterate through all factories identified by the factory entrypoint.

    Yields:
        function: A function that accepts a :class:`.Specification` and
        returns a :class:`.PenaltyModel`.
965066
def iter_factories():
    
    # retrieve all of the factories with
    factories = (entry.load() for entry in iter_entry_points(FACTORY_ENTRYPOINT))

    # sort the factories from highest priority to lowest. Any factory with unknown priority
    # gets assigned priority -1000.
    for factory in sorted(factories, key=lambda f: getattr(f, 'priority', -1000), reverse=True):
        yield factory
430292
def get_factory_kwargs(self):
        
        params = dict()

        exclude = self.derive_exclude()
        exclude += self.derive_readonly()

        if self.fields:
            fields = list(self.fields)
            for ex in exclude:
                if ex in fields:
                    fields.remove(ex)

            params['fields'] = fields

        if exclude:
            params['exclude'] = exclude

        return params
905846
def factory(self, request, parent=None, name=None):
        
        traverse = request.matchdict['traverse']

        # show documentation at the root path
        if not traverse:
            return {}
        else:
            service = {}
            name = name or traverse[0]

            # look for direct pattern matches
            traversed = '/' + '/'.join(traverse)
            service_type = None
            service_object = None

            for route, endpoint in self.routes:
                result = route.match(traversed)
                if result is not None:
                    request.matchdict = result
                    request.endpoint = endpoint
                    break
            else:
                try:
                    service_type, service_object = self.services[name]
                except KeyError:
                    raise HTTPNotFound()

            if service_type:
                if isinstance(service_type, Endpoint):
                    service[name] = service_type
                elif service_object is None:
                    service[name] = service_type(request)
                else:
                    service[name] = service_type(request, service_object)

            request.api_service = service
            return service
1164001
function getDefineFactory(defineExpr) {

    var args = defineExpr.arguments;
    var factoryAst = args[args.length - 1];

    if (factoryAst.type === SYNTAX.FunctionExpression
        || factoryAst.type === SYNTAX.ObjectExpression
        || factoryAst.type === SYNTAX.ArrayExpression
    ) {
        return factoryAst;
    }

    return false;
}
414637
def apply(self, func, workers=1, job_size=10000):
    
    if workers == 1:
      for lines in self.iter_chunks(job_size):
        yield func(lines)
    else:
      with ProcessPoolExecutor(max_workers=workers) as executor:
        for result in executor.map(func, self.iter_chunks(job_size)):
          yield result
195147
def functions(start=None, end=None):
    
    start, end = fix_addresses(start, end)

    for func_t in idautils.Functions(start, end):
        yield Function(func_t)
538104
def iofunctions(self):
        """"""
        lines = Lines()
        for func in ('open_files', 'close_files', 'load_data', 'save_data'):
            if ((func == 'load_data') and
                    (getattr(self.model.sequences, 'inputs', None) is None)):
                continue
            if ((func == 'save_data') and
                ((getattr(self.model.sequences, 'fluxes', None) is None) and
                 (getattr(self.model.sequences, 'states', None) is None))):
                continue
            print('            . %s' % func)
            nogil = func in ('load_data', 'save_data')
            idx_as_arg = func == 'save_data'
            lines.add(1, method_header(
                func, nogil=nogil, idx_as_arg=idx_as_arg))
            for subseqs in self.model.sequences:
                if func == 'load_data':
                    applyfuncs = ('inputs',)
                elif func == 'save_data':
                    applyfuncs = ('fluxes', 'states')
                else:
                    applyfuncs = ('inputs', 'fluxes', 'states')
                if subseqs.name in applyfuncs:
                    if func == 'close_files':
                        lines.add(2, 'self.sequences.%s.%s()'
                                     % (subseqs.name, func))
                    else:
                        lines.add(2, 'self.sequences.%s.%s(self.idx_sim)'
                                     % (subseqs.name, func))
        return lines
80362
def _runDeferredFunctions(deferredFunctions):
        
        failures = []
        for deferredFunction in deferredFunctions:
            try:
                deferredFunction.invoke()
            except:
                failures.append(deferredFunction.name)
                logger.exception('%s failed.', deferredFunction)
        return failures
941605
function makePromise(requestInstance, promiseFactoryFn) {

  // Resolver function wich assigns the promise (resolve, reject) functions
  // to the requestInstance
  function Resolver(resolve, reject) {
    this._resolve = resolve;
    this._reject = reject;
  }

  return promiseFactoryFn(Resolver.bind(requestInstance));
}
1185018
async def traverse(self, func):
        

        # this allows the reference to be stolen
        async_executor = self

        if inspect.isasyncgenfunction(func):
            async for result in func(*async_executor.args):
                yield result
        else:
            yield await func(*async_executor.args)
268885
def Interpolate(self):
    
    for var_config in collection.DictProduct(self._var_bindings):
      for scope_config in collection.DictProduct(self._scope_bindings):
        subst = Substitution(var_config=var_config, scope_config=scope_config)
        yield subst.Substitute(self._pattern)
109955
async def factory(self, request, path = "/", as_ = None):
    
    counter, time = perf_counter(), process_time()
    if not path.startswith("/"):
      path = "/{}".format(path)

    resp = await self.resolve_path(path)
    if resp:
      if "path" not in request.json:
        request.json["path"] = path

      method = getattr(resp["model"], resp["model"].factories[as_] if hasattr(resp["model"], "factories") and as_ in resp["model"].factories else "create_child")
      result = await method(request, as_)
      code = result.code if issubclass(result.__class__, ErrorSchema) else 201
      result = result.to_plain_dict()

      result['pref_counter'] = (perf_counter() - counter) * 1000
      result['process_time'] = (process_time() - time) * 1000
      return response.json(result, code)
    else:
      error = self.models.ErrorSchema()
      error.load({"message": "{} not found".format(path), "code": 404})
      return response.json(error.to_plain_dict(), 404)
902372
def argument_getter_factory(route_spec):
     
    
    func_sig = inspect.signature(route_spec.handler_func)

    param_names = list(func_sig.parameters.keys())
    arg_getters  = build_argval_getters(route_spec)
    n_args = len(arg_getters)

    async def argument_getters(request):
        errors = None
        values = {}
        for i in range(n_args):
            try:
                arg_name = param_names[i]
                values[arg_name] = await arg_getters[i](request)
            except HTTPException:
                raise
            except Exception as exc :
                if errors is None: 
                    errors = []

                request.app.logger.error('', exc_info=True)

                exc_type = type(exc)

                data = {
                    "name": arg_name, 
                    "type": f"{exc_type.__module__}.{exc_type.__qualname__}",
                    "error": str(exc)
                }

                errors.append(data)

        if errors is not None:
            raise RESTfulArgumentError(errors)

        return values

    return argument_getters
943758
def _yield_estimators(model):
    
    yield from _yield_preproc_steps(model)

    net_prefixes = []
    module_prefixes = []

    if isinstance(model, Pipeline):
        name = model.steps[-1][0]
        net_prefixes.append(name)
        module_prefixes.append(name)
        net = model.steps[-1][1]
    else:
        net = model

    yield '__'.join(net_prefixes), net

    module = net.module
    module_prefixes.append('module')
    yield '__'.join(module_prefixes), module
1007564
def factory(cls, **kwargs):
    
    for name, obj in inspect.getmembers(sys.modules[__name__]):
        if inspect.isclass(obj) and issubclass(obj, UserAuthnMethod):
            try:
                if obj.__name__ == cls:
                    return obj(**kwargs)
            except AttributeError:
                pass
1270211
def iter_methods(self):
        
        for wrkey, obj in self.iter_instances():
            f, obj_id = wrkey
            loop = self.event_loop_map[wrkey]
            m = getattr(obj, f.__name__)
            yield loop, m
243429
function define(id, deps, exp) {
		if (!exp) { exp = deps; deps = [ 'require', 'exports', 'module' ]; }
		var module = getModule(undefined, id);
		module.children = map(deps, function(dep) { return getModule(module, dep); });
		module.loaded = true;
		factories[id] = exp;
		fireWaits(module);
	}