当前位置: 首页>>代码示例>>Python>>正文


Python nodes.classifier方法代码示例

本文整理汇总了Python中docutils.nodes.classifier方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.classifier方法的具体用法?Python nodes.classifier怎么用?Python nodes.classifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在docutils.nodes的用法示例。


在下文中一共展示了nodes.classifier方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: term

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def term(self, lines, lineno):
        """Return a definition_list's term and optional classifiers."""
        assert len(lines) == 1
        text_nodes, messages = self.inline_text(lines[0], lineno)
        term_node = nodes.term()
        (term_node.source,
         term_node.line) = self.state_machine.get_source_and_line(lineno)
        term_node.rawsource = unescape(lines[0])
        node_list = [term_node]
        for i in range(len(text_nodes)):
            node = text_nodes[i]
            if isinstance(node, nodes.Text):
                parts = self.classifier_delimiter.split(node.rawsource)
                if len(parts) == 1:
                    node_list[-1] += node
                else:

                    node_list[-1] += nodes.Text(parts[0].rstrip())
                    for part in parts[1:]:
                        classifier_node = nodes.classifier('', part)
                        node_list.append(classifier_node)
            else:
                node_list[-1] += node
        return node_list, messages 
开发者ID:skarlekar,项目名称:faces,代码行数:26,代码来源:states.py

示例2: term

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def term(self, lines, lineno):
        """Return a definition_list's term and optional classifiers."""
        assert len(lines) == 1
        text_nodes, messages = self.inline_text(lines[0], lineno)
        term_node = nodes.term(lines[0])
        (term_node.source,
         term_node.line) = self.state_machine.get_source_and_line(lineno)
        node_list = [term_node]
        for i in range(len(text_nodes)):
            node = text_nodes[i]
            if isinstance(node, nodes.Text):
                parts = self.classifier_delimiter.split(node)
                if len(parts) == 1:
                    node_list[-1] += node
                else:
                    text = parts[0].rstrip()
                    textnode = nodes.Text(utils.unescape(text, True))
                    node_list[-1] += textnode
                    for part in parts[1:]:
                        node_list.append(
                            nodes.classifier(unescape(part, True), part))
            else:
                node_list[-1] += node
        return node_list, messages 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:26,代码来源:states.py

示例3: map_nested_definitions

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def map_nested_definitions(nested_content):
    if nested_content is None:
        raise Exception('Nested content should be iterable, not null')
    # build definition dictionary
    definitions = {}
    for item in nested_content:
        if not isinstance(item, nodes.definition_list):
            continue
        for subitem in item:
            if not isinstance(subitem, nodes.definition_list_item):
                continue
            if not len(subitem.children) > 0:
                continue
            classifier = '@after'
            idx = subitem.first_child_matching_class(nodes.classifier)
            if idx is not None:
                ci = subitem[idx]
                if len(ci.children) > 0:
                    classifier = ci.children[0].astext()
            if classifier is not None and classifier not in (
                    '@replace', '@before', '@after'):
                raise Exception('Unknown classifier: %s' % classifier)
            idx = subitem.first_child_matching_class(nodes.term)
            if idx is not None:
                term = subitem[idx]
                if len(term.children) > 0:
                    term = term.children[0].astext()
                    idx = subitem.first_child_matching_class(nodes.definition)
                    if idx is not None:
                        subContent = []
                        for _ in subitem[idx]:
                            if isinstance(_, nodes.definition_list):
                                subContent.append(_)
                        definitions[term] = (classifier, subitem[idx].astext(), subContent)

    return definitions 
开发者ID:rucio,项目名称:rucio,代码行数:38,代码来源:ext.py

示例4: visit_definition_list_item

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def visit_definition_list_item(self, node):
        self._li_has_classifier = len(node) >= 2 and \
                                  isinstance(node[1], nodes.classifier) 
开发者ID:skarlekar,项目名称:faces,代码行数:5,代码来源:textwriter.py

示例5: map_nested_definitions

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def map_nested_definitions(nested_content):
    if nested_content is None:
        raise Exception('Nested content should be iterable, not null')
    # build definition dictionary
    definitions = {}
    for item in nested_content:
        if not isinstance(item, nodes.definition_list):
            continue
        for subitem in item:
            if not isinstance(subitem, nodes.definition_list_item):
                continue
            if not len(subitem.children) > 0:
                continue
            classifier = '@after'
            idx = subitem.first_child_matching_class(nodes.classifier)
            if idx is not None:
                ci = subitem[idx]
                if len(ci.children) > 0:
                    classifier = ci.children[0].astext()
            if classifier is not None and classifier not in (
                    '@replace', '@before', '@after'):
                raise Exception('Unknown classifier: %s' % classifier)
            idx = subitem.first_child_matching_class(nodes.term)
            if idx is not None:
                ch = subitem[idx]
                if len(ch.children) > 0:
                    term = ch.children[0].astext()
                    idx = subitem.first_child_matching_class(nodes.definition)
                    if idx is not None:
                        def_node = subitem[idx]
                        def_node.attributes['classifier'] = classifier
                        definitions[term] = def_node
    return definitions 
开发者ID:pnnl,项目名称:safekit,代码行数:35,代码来源:ext.py

示例6: apply_definition

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def apply_definition(definitions, my_def, name):
    if name in definitions:
        definition = definitions[name]
        classifier = definition['classifier']
        if classifier == '@replace':
            return definition.children
        if classifier == '@after':
            return my_def + definition.children
        if classifier == '@before':
            return definition.children + my_def
        raise Exception('Unknown classifier: %s' % classifier)
    return my_def 
开发者ID:pnnl,项目名称:safekit,代码行数:14,代码来源:ext.py

示例7: visit_definition_list_item

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def visit_definition_list_item(self, node):
        self._li_has_classifier = len(node) >= 2 and \
            isinstance(node[1], nodes.classifier) 
开发者ID:openstack,项目名称:releases,代码行数:5,代码来源:rst2txt.py

示例8: visit_definition_list_item

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def visit_definition_list_item(self, node):
    self._li_has_classifier = len(node) >= 2 and \
                              isinstance(node[1], nodes.classifier) 
开发者ID:intelligent-agent,项目名称:redeem,代码行数:5,代码来源:TextWriter.py

示例9: print_subcommands

# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import classifier [as 别名]
def print_subcommands(data, nested_content, markDownHelp=False):
    """
    Each subcommand is a dictionary with the following keys:

    ['usage', 'action_groups', 'bare_usage', 'name', 'help', 'epilog']

    In essence, this is all tossed in a new section with the title 'name'.
    Apparently there can also be a 'description' entry.
    """

    definitions = map_nested_definitions(nested_content)
    items = []
    if 'children' in data:
        subCommands = nodes.section(ids=["Sub-commands:"])
        subCommands += nodes.title('Sub-commands:', 'Sub-commands:')

        for child in data['children']:
            sec = nodes.section(ids=[child['name']])
            sec += nodes.title(child['name'], child['name'])

            if 'description' in child and child['description']:
                desc = [child['description']]
            elif child['help']:
                desc = [child['help']]
            else:
                desc = ['Undocumented']

            # Handle nested content
            subContent = []
            if child['name'] in definitions:
                classifier, s, subContent = definitions[child['name']]
                if classifier == '@replace':
                    desc = [s]
                elif classifier == '@after':
                    desc.append(s)
                elif classifier == '@before':
                    desc.insert(0, s)

            for element in renderList(desc, markDownHelp):
                sec += element
            sec += nodes.literal_block(text=child['bare_usage'])
            for x in print_action_groups(child, nested_content + subContent, markDownHelp):
                sec += x

            for x in print_subcommands(child, nested_content + subContent, markDownHelp):
                sec += x

            if 'epilog' in child and child['epilog']:
                for element in renderList([child['epilog']], markDownHelp):
                    sec += element

            subCommands += sec

        items.append(subCommands)

    return items 
开发者ID:rucio,项目名称:rucio,代码行数:58,代码来源:ext.py


注:本文中的docutils.nodes.classifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。