本文整理汇总了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()
示例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
示例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)
示例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