Initialize template args.
778215
def _default_template_args(self, content_template):
    """"""
    def include(text, args):
      template_name = pystache.render(text, args)
      return self._renderer.render_name(template_name, args)
    # Our base template calls include on the content_template.
    ret = {'content_template': content_template}
    ret['include'] = lambda text: include(text, ret)
    return ret
1312523
public static void initInstance(Context context, String meteorServerHostname) {
        initInstance(context, meteorServerHostname, sMeteorPort, false);
    }
432615
public function initializeArguments()
    {
        parent::initializeArguments();
        $this->registerArgument('page', 'int', 'The page', false, 0);
        $this->registerArgument('groupItem', GroupItem::class, 'The group item', true);

    }
150461
public static function init() {
		self::$tpl_auto_config = Yesf::app()->getConfig('view.auto', Yesf::CONF_PROJECT) === true;
		self::$tpl_extension = Yesf::app()->getConfig('view.extension', Yesf::CONF_PROJECT, 'phtml');
		self::$tpl_engine = Template::class;
		Container::getInstance()->setMulti(Template::class, Container::MULTI_CLONE);
	}
516200
private void initIndexTemplate(String type) {
        String template = "template_" + type;
        try {
            if (doesResourceNotExist("/_template/" + template)) {
                logger.info("Creating the index template '" + template + "'");
                InputStream stream = ElasticSearchDAOV6.class.getResourceAsStream("/" + template + ".json");
                byte[] templateSource = IOUtils.toByteArray(stream);

                HttpEntity entity = new NByteArrayEntity(templateSource, ContentType.APPLICATION_JSON);
                elasticSearchAdminClient.performRequest(HttpMethod.PUT, "/_template/" + template, Collections.emptyMap(), entity);
            }
        } catch (Exception e) {
            logger.error("Failed to init " + template, e);
        }
    }
686464
def run_initializer(initializer, initargs):
    """"""
    try:
        initializer(*initargs)
        return True
    except Exception as error:
        logging.exception(error)
        return False
266465
def main(argv=None):
    """"""
    arguments = cli_common(__doc__, argv=argv)
    plugin = 'benchmark' if arguments['benchmark'] else None

    if arguments['-g']:
        template.generate_config(plugin, arguments['<FILE>'])
    else:
        with open(arguments['<FILE>']) as istr:
            context = json.load(istr)
        kwargs = dict(no_input=True, extra_context=context)
        if arguments['--output-dir']:
            kwargs.update(output_dir=arguments['--output-dir'])
        if arguments['--interactive']:
            kwargs.update(no_input=False)
        logging.info(
            'generating template in directory ' + kwargs.get('output_dir', os.getcwd())
        )
        template.generate_template(plugin, **kwargs)
832259
protected function initializeNodeTemplates()
    {
        $this->nodeType = $this->nodeTypeManager->getNodeType($this->nodeTypeName);
        $this->nodeTemplate = new NodeTemplate();
        $this->nodeTemplate->setNodeType($this->nodeType);
    }
658156
public function initialize() {
    $this->uuidGenerator = new Php();
    $template_dir = $this->getConfigValue('blt.root') . '/scripts/config-split/templates';
    $loader = new \Twig_Loader_Filesystem($template_dir);
    $this->twig = new \Twig_Environment($loader);
    $docroot = $this->getConfigValue('docroot');
    $this->configSyncDir = $docroot . '/' . $this->getConfigValue('cm.core.dirs.sync.path');
    $this->configSplitDir = $docroot . '/' . $this->getConfigValue('cm.core.path') . '/envs';
  }
627702
def _get_init_args(self):
        """"""

        args = {}
        for rop in self.ro_properties:
            if rop in self.properties:
                args[rop] = self.properties[rop]
        return args
66090
def _init_params(self, inputs, overwrite=False):
        """"""
        inputs = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in inputs]
        input_shapes = {item.name: item.shape for item in inputs}
        arg_shapes, _, aux_shapes = self.symbol.infer_shape(**input_shapes)
        assert arg_shapes is not None
        input_dtypes = {item.name: item.dtype for item in inputs}
        arg_dtypes, _, aux_dtypes = self.symbol.infer_type(**input_dtypes)
        assert arg_dtypes is not None

        arg_names = self.symbol.list_arguments()
        input_names = input_shapes.keys()
        param_names = [key for key in arg_names if key not in input_names]
        aux_names = self.symbol.list_auxiliary_states()

        param_name_attrs = [x for x in zip(arg_names, arg_shapes, arg_dtypes)
                            if x[0] in param_names]
        arg_params = {k : nd.zeros(shape=s, dtype=t)
                      for k, s, t in param_name_attrs}
        aux_name_attrs = [x for x in zip(aux_names, aux_shapes, aux_dtypes)
                          if x[0] in aux_names]
        aux_params = {k : nd.zeros(shape=s, dtype=t)
                      for k, s, t in aux_name_attrs}

        for k, v in arg_params.items():
            if self.arg_params and k in self.arg_params and (not overwrite):
                arg_params[k][:] = self.arg_params[k][:]
            else:
                self.initializer(k, v)

        for k, v in aux_params.items():
            if self.aux_params and k in self.aux_params and (not overwrite):
                aux_params[k][:] = self.aux_params[k][:]
            else:
                self.initializer(k, v)

        self.arg_params = arg_params
        self.aux_params = aux_params
        return (arg_names, list(param_names), aux_names)
119982
public function init()
    {
        $this->typeTemplate = strtr($this->typeTemplate, array('{class}' => $this->chartCssClass));
        parent::init();
    }
388677
def check_arguments(cls, passed):
        """"""
        defaults = list(cls.default_arguments().keys())
        template = ("Pass arg {argument:!r} in {cname:!r}, can be a typo? "
                    "Supported key arguments: {defaults}")
        fails = []
        for arg in passed:
            if arg not in defaults:
                warn(template.format(argument=arg,
                                     cname=cls.__name__,
                                     defaults=defaults))
                fails.append(arg)

        return any(fails)
831270
def _initialize(self, *args, **kwargs):
        """"""
        self.items = None
        self.keys = None
        self.values = None

        if args:
            if len(args) != 2:
                raise TypeError("expected exactly two positional arguments, "
                                "got %s" % len(args))
            if kwargs:
                raise TypeError(
                    "expected positional or keyword arguments, not both")

            # got positional arguments only
            self.keys, self.values = map(self._validate_argument, args)
        elif kwargs:
            has_kv = 'keys' in kwargs and 'values' in kwargs
            has_of = 'of' in kwargs
            if not (has_kv or has_of):
                raise TypeError("expected keys/values or items matchers, "
                                "but got: %s" % list(kwargs.keys()))
            if has_kv and has_of:
                raise TypeError(
                    "expected keys & values, or items matchers, not both")

            if has_kv:
                # got keys= and values= matchers
                self.keys = self._validate_argument(kwargs['keys'])
                self.values = self._validate_argument(kwargs['values'])
            else:
                # got of= matcher, which can be a tuple of matchers,
                # or a single matcher for dictionary items
                of = kwargs['of']
                if isinstance(of, tuple):
                    try:
                        # got of= as tuple of matchers
                        self.keys, self.values = \
                            map(self._validate_argument, of)
                    except ValueError:
                        raise TypeError(
                            "of= tuple has to be a pair of matchers/types" % (
                                self.__class__.__name__,))
                else:
                    # got of= as a single matcher
                    self.items = self._validate_argument(of)
643899
def init(self, *args):
        '''
        '''
        cfg = {}
        for k, v in self.options.items():
            if k.lower() in self.cfg.settings and v is not None:
                cfg[k.lower()] = v
        return cfg
87452
def generate_template(template_name, **context):
    """"""
    context.update(href=href, format_datetime=format_datetime)
    return template_loader.load(template_name).generate(**context)
628784
def do_init(argdict):
    ''''''
    site = make_site_obj(argdict)
    try:
        site.init_structure()
        print "Initialized directory."
        if argdict['randomsite']:
            #all_tags = ['tag1','tag2','tag3','tag4']
            for i in range(1,argdict['numpages']+1):
                #ptags = random.sample(all_tags,random.randint(1,len(all_tags)))
                p = site.random_page()
                p.set_published()
                p.write()
                print "added page ",p.slug
    except ValueError: # pragma: no cover
        print "Cannot create structure. You're already within an s2 \
tree, or the directory is not empty or it is not writeable. "