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


Python token.COLON屬性代碼示例

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


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

示例1: suitify

# 需要導入模塊: from lib2to3.pygram import token [as 別名]
# 或者: from lib2to3.pygram.token import COLON [as 別名]
def suitify(parent):
    """
    Turn the stuff after the first colon in parent's children
    into a suite, if it wasn't already
    """
    for node in parent.children:
        if node.type == syms.suite:
            # already in the prefered format, do nothing
            return

    # One-liners have no suite node, we have to fake one up
    for i, node in enumerate(parent.children):
        if node.type == token.COLON:
            break
    else:
        raise ValueError(u"No class suite and no ':'!")
    # Move everything into a suite node
    suite = Node(syms.suite, [Newline(), Leaf(token.INDENT, indentation(node) + indentation_step(node))])
    one_node = parent.children[i+1]
    one_node.remove()
    one_node.prefix = u''
    suite.append_child(one_node)
    parent.append_child(suite) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:25,代碼來源:fixer_util.py

示例2: fixup_parse_tree

# 需要導入模塊: from lib2to3.pygram import token [as 別名]
# 或者: from lib2to3.pygram.token import COLON [as 別名]
def fixup_parse_tree(cls_node):
    """ one-line classes don't get a suite in the parse tree so we add
        one to normalize the tree
    """
    for node in cls_node.children:
        if node.type == syms.suite:
            # already in the preferred format, do nothing
            return

    # !%@#! oneliners have no suite node, we have to fake one up
    for i, node in enumerate(cls_node.children):
        if node.type == token.COLON:
            break
    else:
        raise ValueError("No class suite and no ':'!")

    # move everything into a suite node
    suite = Node(syms.suite, [])
    while cls_node.children[i+1:]:
        move_node = cls_node.children[i+1]
        suite.append_child(move_node.clone())
        move_node.remove()
    cls_node.append_child(suite)
    node = suite 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:26,代碼來源:fix_metaclass.py

示例3: suitify

# 需要導入模塊: from lib2to3.pygram import token [as 別名]
# 或者: from lib2to3.pygram.token import COLON [as 別名]
def suitify(parent):
    u"""
    Turn the stuff after the first colon in parent's children
    into a suite, if it wasn't already
    """
    for node in parent.children:
        if node.type == syms.suite:
            # already in the prefered format, do nothing
            return

    # One-liners have no suite node, we have to fake one up
    for i, node in enumerate(parent.children):
        if node.type == token.COLON:
            break
    else:
        raise ValueError(u"No class suite and no ':'!")
    # Move everything into a suite node
    suite = Node(syms.suite, [Newline(), Leaf(token.INDENT, indentation(node) + indentation_step(node))])
    one_node = parent.children[i+1]
    one_node.remove()
    one_node.prefix = u''
    suite.append_child(one_node)
    parent.append_child(suite) 
開發者ID:hughperkins,項目名稱:kgsgo-dataset-preprocessor,代碼行數:25,代碼來源:fixer_util.py


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