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


Python token.EQUAL屬性代碼示例

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


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

示例1: transform

# 需要導入模塊: from lib2to3.pgen2 import token [as 別名]
# 或者: from lib2to3.pgen2.token import EQUAL [as 別名]
def transform(self, node, results):
        next_sibling = node.next_sibling
        if (
            next_sibling
            and next_sibling.type == token.EQUAL
            and next_sibling.value == "="
        ):
            return
        prev_sibling = node.prev_sibling
        if prev_sibling and prev_sibling.type == token.NAME:
            if prev_sibling.value in ("del", "in"):
                return
        method = results["method"]
        method_node = method.parent
        if str(method_node.next_sibling) in (".clear", ".update"):
            return
        libmodernize.touch_import("scalyr_agent", "compat", node)
        head = results["head"]
        head.value = head.value.replace("os", "compat")
        method.value = "os_environ_unicode"
        node.changed() 
開發者ID:scalyr,項目名稱:scalyr-agent-2,代碼行數:23,代碼來源:fix_os_environ_unicode.py

示例2: is_assign_target

# 需要導入模塊: from lib2to3.pgen2 import token [as 別名]
# 或者: from lib2to3.pgen2.token import EQUAL [as 別名]
def is_assign_target(node):
    assign = find_assign(node)
    if assign is None:
        return False

    for child in assign.children:
        if child.type == token.EQUAL:
            return False
        elif is_subtree(child, node):
            return True
    return False 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:13,代碼來源:fix_next_call.py

示例3: add_kwarg

# 需要導入模塊: from lib2to3.pgen2 import token [as 別名]
# 或者: from lib2to3.pgen2.token import EQUAL [as 別名]
def add_kwarg(self, l_nodes, s_kwd, n_expr):
        # XXX All this prefix-setting may lose comments (though rarely)
        n_expr.prefix = u""
        n_argument = pytree.Node(self.syms.argument,
                                 (Name(s_kwd),
                                  pytree.Leaf(token.EQUAL, u"="),
                                  n_expr))
        if l_nodes:
            l_nodes.append(Comma())
            n_argument.prefix = u" "
        l_nodes.append(n_argument) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:13,代碼來源:fix_print.py

示例4: count_args

# 需要導入模塊: from lib2to3.pgen2 import token [as 別名]
# 或者: from lib2to3.pgen2.token import EQUAL [as 別名]
def count_args(node, results):
    # type: (Node, Dict[str, Base]) -> Tuple[int, bool, bool, bool]
    """Count arguments and check for self and *args, **kwds.

    Return (selfish, count, star, starstar) where:
    - count is total number of args (including *args, **kwds)
    - selfish is True if the initial arg is named 'self' or 'cls'
    - star is True iff *args is found
    - starstar is True iff **kwds is found
    """
    count = 0
    selfish = False
    star = False
    starstar = False
    args = results.get('args')
    if isinstance(args, Node):
        children = args.children
    elif isinstance(args, Leaf):
        children = [args]
    else:
        children = []
    # Interpret children according to the following grammar:
    # (('*'|'**')? NAME ['=' expr] ','?)*
    skip = False
    previous_token_is_star = False
    for child in children:
        if skip:
            skip = False
        elif isinstance(child, Leaf):
            # A single '*' indicates the rest of the arguments are keyword only
            # and shouldn't be counted as a `*`.
            if child.type == token.STAR:
                previous_token_is_star = True
            elif child.type == token.DOUBLESTAR:
                starstar = True
            elif child.type == token.NAME:
                if count == 0:
                    if child.value in ('self', 'cls'):
                        selfish = True
                count += 1
                if previous_token_is_star:
                    star = True
            elif child.type == token.EQUAL:
                skip = True
            if child.type != token.STAR:
                previous_token_is_star = False
    return count, selfish, star, starstar 
開發者ID:dropbox,項目名稱:pyannotate,代碼行數:49,代碼來源:fix_annotate_json.py


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