本文整理汇总了Python中lib2to3.fixer_util.syms.raise_stmt方法的典型用法代码示例。如果您正苦于以下问题:Python syms.raise_stmt方法的具体用法?Python syms.raise_stmt怎么用?Python syms.raise_stmt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib2to3.fixer_util.syms
的用法示例。
在下文中一共展示了syms.raise_stmt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform
# 需要导入模块: from lib2to3.fixer_util import syms [as 别名]
# 或者: from lib2to3.fixer_util.syms import raise_stmt [as 别名]
def transform(self, node, results):
FIXME
name, val, trc = (results.get(u"name"), results.get(u"val"), results.get(u"trc"))
chain = results.get(u"chain")
if chain is not None:
self.warning(node, u"explicit exception chaining is not supported in Python 2")
chain.prev_sibling.remove()
chain.remove()
if trc is not None:
val = val[0] if val else Leaf(token.NAME, u"None")
val.prefix = trc.prefix = u" "
kids = [Leaf(token.NAME, u"raise"), name.clone(), Comma(),
val.clone(), Comma(), trc.clone()]
raise_stmt = Node(syms.raise_stmt, kids)
node.replace(raise_stmt)
示例2: transform
# 需要导入模块: from lib2to3.fixer_util import syms [as 别名]
# 或者: from lib2to3.fixer_util.syms import raise_stmt [as 别名]
def transform(self, node, results):
name, val, trc = (results.get(u"name"), results.get(u"val"), results.get(u"trc"))
chain = results.get(u"chain")
if chain is not None:
self.warning(node, u"explicit exception chaining is not supported in Python 2")
chain.prev_sibling.remove()
chain.remove()
if trc is not None:
val = val[0] if val else Leaf(token.NAME, u"None")
val.prefix = trc.prefix = u" "
kids = [Leaf(token.NAME, u"raise"), name.clone(), Comma(),
val.clone(), Comma(), trc.clone()]
raise_stmt = Node(syms.raise_stmt, kids)
node.replace(raise_stmt)