當前位置: 首頁>>代碼示例>>Python>>正文


Python pystache.render方法代碼示例

本文整理匯總了Python中pystache.render方法的典型用法代碼示例。如果您正苦於以下問題:Python pystache.render方法的具體用法?Python pystache.render怎麽用?Python pystache.render使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pystache的用法示例。


在下文中一共展示了pystache.render方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_colorscheme

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def get_colorscheme(self, scheme_file):
        """Return a string object with the colorscheme that is to be
        inserted."""
        scheme = get_yaml_dict(scheme_file)
        scheme_slug = builder.slugify(scheme_file)
        builder.format_scheme(scheme, scheme_slug)

        try:
            temp_base, temp_sub = self.temp.split("##")
        except ValueError:
            temp_base, temp_sub = (self.temp.strip("##"), "default")

        temp_path = rel_to_cwd("templates", temp_base)
        temp_group = builder.TemplateGroup(temp_path)
        try:
            single_temp = temp_group.templates[temp_sub]
        except KeyError:
            raise FileNotFoundError(None, None, self.path + " (sub-template)")

        colorscheme = pystache.render(single_temp["parsed"], scheme)
        return colorscheme 
開發者ID:InspectorMustache,項目名稱:base16-builder-python,代碼行數:23,代碼來源:injector.py

示例2: read_file

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def read_file(self, filename, render_variables=False, as_binary=False):
        if filename.startswith("vault:"):
            if filename.startswith("vault::"):
                if not self.global_config or "vault" not in self.global_config or "key" not in self.global_config["vault"]:
                    raise ConfigurationException("vault definition without key but no key is defined in global config: %s" % filename)
                _, filename = filename.split("::", 1)
                key = self.variables_container.render(self.global_config["vault"]["key"])
            else:
                _, key, filename = filename.split(":", 2)
        else:
            key = None
        filepath = self.abspath(filename)
        mode = "r"
        if as_binary:
            mode = "rb"
        with open(filepath, mode) as file_obj:
            data = file_obj.read()
        if key:
            check_if_encrypted_is_older(filepath)
            data = decrypt_data(key, data)
        if render_variables:
            data = self.variables_container.render(data)
        return data 
開發者ID:MaibornWolff,項目名稱:dcos-deploy,代碼行數:25,代碼來源:reader.py

示例3: render

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def render(self, text):
        variables = {**self.variables, **self.extra_vars}
        result_text = pystache.render(text, variables)
        if result_text.count("{{"):
            raise ConfigurationException("Unresolved variable")
        return result_text 
開發者ID:MaibornWolff,項目名稱:dcos-deploy,代碼行數:8,代碼來源:variables.py

示例4: _read_variable_value_from_file

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def _read_variable_value_from_file(self, base_path, fileconfig):
        if isinstance(fileconfig, dict):
            filename = fileconfig["path"]
            render = fileconfig.get("render", False)
        else:
            filename = fileconfig
            render = False
        if filename.startswith("vault:"):
            _, key, filename = filename.split(":", 2)
            if not key:
                if not self._vault_key:
                    raise ConfigurationException("vault definition without key but no key is defined in global config: %s" % filename)
                key = self._vault_key
        else:
            key = None
        filename = self.render_value(filename)
        absolute_path = os.path.abspath(os.path.join(base_path, filename))
        if key:
            check_if_encrypted_is_older(absolute_path)
        with open(absolute_path) as var_file:
            value = var_file.read()
        if key:
            key = self.render_value(key)
            value = decrypt_data(key, value)
        if render:
            value = pystache.render(value, self.variables)
        return value 
開發者ID:MaibornWolff,項目名稱:dcos-deploy,代碼行數:29,代碼來源:variables.py

示例5: render_value

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def render_value(self, value, extra_vars=dict()):
        if extra_vars:
            variables = {**self.variables, **extra_vars}
        else:
            variables = self.variables
        return pystache.render(value, variables) 
開發者ID:MaibornWolff,項目名稱:dcos-deploy,代碼行數:8,代碼來源:variables.py

示例6: render

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def render(self, text):
        if text is None:
            return None
        return self.variables_container.render(text) 
開發者ID:MaibornWolff,項目名稱:dcos-deploy,代碼行數:6,代碼來源:reader.py

示例7: _expand_loop

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def _expand_loop(key, values):
    loop = values["loop"]
    del values["loop"]
    extra_vars = values.get("extra_vars", dict())
    loop_vars = loop.keys()
    if "{{" in key:
        name_template = key
    else:
        name_template = "%s-%s" % (key, '-'.join(["{{%s}}" % var for var in loop_vars]))
    for combination in itertools.product(*[loop[var] for var in loop_vars]):
        variables = {**extra_vars, **dict([(var, combination[idx]) for idx, var in enumerate(loop_vars)])}
        name = pystache.render(name_template, variables)
        entity_config = copy.deepcopy(values)
        entity_config["extra_vars"] = variables
        yield name, entity_config 
開發者ID:MaibornWolff,項目名稱:dcos-deploy,代碼行數:17,代碼來源:reader.py

示例8: _synthesize

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def _synthesize(self, attributes, requester, provider):
        syn_attributes = dict()
        context = dict()
        
        for attr_name,values in attributes.items():
           context[attr_name] = MustachAttrValue(attr_name, values)

        recipes = get_dict_defaults(self.synthetic_attributes, requester, provider)
        for attr_name, fmt in recipes.items():
           syn_attributes[attr_name] = [v.strip().strip(';') for v in re.split("[;\n]+", pystache.render(fmt, context))]
        return syn_attributes 
開發者ID:IdentityPython,項目名稱:SATOSA,代碼行數:13,代碼來源:attribute_generation.py

示例9: generateMain

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def generateMain(commands):
    txt = []

    with open("templates/mbed.tmplt") as fp:
        tmplt = fp.read()

    txt.append(pystache.render(tmplt, commands))

    return txt 
開發者ID:ARMmbed,項目名稱:mbed-cli,代碼行數:11,代碼來源:generator.py

示例10: generateCompleters

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def generateCompleters(commands):
    txt = []

    renderer = pystache.Renderer(escape=lambda u: u)

    with open("templates/command.tmplt") as fp:
        tmplt = fp.read()

    for commandKey in commands:
        txt.append(renderer.render(tmplt, commands[commandKey]))

        # if need to add hacks add them here

    return txt 
開發者ID:ARMmbed,項目名稱:mbed-cli,代碼行數:16,代碼來源:generator.py

示例11: load_networkx_graph

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def load_networkx_graph(self, rdfgraph: rdflib.Graph = None, predicates: Set[URIRef] = None, **kwargs) -> None:
        """
        Fetch triples from the SPARQL endpoint and load them as edges.

        Parameters
        ----------
        rdfgraph: rdflib.Graph
            A rdflib Graph (unused)
        predicates: set
            A set containing predicates in rdflib.URIRef form
        kwargs: dict
            Any additional arguments.

        """
        for predicate in predicates:
            predicate = '<{}>'.format(predicate)
            q = render(self.edge_query, {'predicate': predicate})
            results = self.query(q)
            for r in results:
                s = r['subject']['value']
                p = r['predicate']['value']
                o = r['object']['value']
                if r['object']['type'] == 'literal':
                    self.add_node_attribute(s, key=p, value=o)
                else:
                    self.add_edge(s, o, p) 
開發者ID:NCATS-Tangerine,項目名稱:kgx,代碼行數:28,代碼來源:sparql_transformer.py

示例12: compact

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def compact(self):
        fmt = inspect.cleandoc(self.COMPACT_FMT)
        return pystache.render(fmt, self) 
開發者ID:EricssonResearch,項目名稱:calvin-base,代碼行數:5,代碼來源:docobject.py

示例13: detailed

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def detailed(self):
        fmt = inspect.cleandoc(self.DETAILED_FMT_PLAIN)
        return pystache.render(fmt, self) 
開發者ID:EricssonResearch,項目名稱:calvin-base,代碼行數:5,代碼來源:docobject.py

示例14: markdown

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def markdown(self):
        DocObject.use_links = False
        fmt = inspect.cleandoc(self.DETAILED_FMT_MD)
        return pystache.render(fmt, self) 
開發者ID:EricssonResearch,項目名稱:calvin-base,代碼行數:6,代碼來源:docobject.py

示例15: markdown_links

# 需要導入模塊: import pystache [as 別名]
# 或者: from pystache import render [as 別名]
def markdown_links(self):
        DocObject.use_links = True
        fmt = inspect.cleandoc(self.DETAILED_FMT_MD)
        return pystache.render(fmt, self) 
開發者ID:EricssonResearch,項目名稱:calvin-base,代碼行數:6,代碼來源:docobject.py


注:本文中的pystache.render方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。