Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/libpasteurize/fixes/fix_raise_.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author | guerler |
---|---|
date | Fri, 31 Jul 2020 00:32:28 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:d30785e31577 | 1:56ad4e20f292 |
---|---|
1 u"""Fixer for | |
2 raise E(V).with_traceback(T) | |
3 to: | |
4 from future.utils import raise_ | |
5 ... | |
6 raise_(E, V, T) | |
7 | |
8 TODO: FIXME!! | |
9 | |
10 """ | |
11 | |
12 from lib2to3 import fixer_base | |
13 from lib2to3.fixer_util import Comma, Node, Leaf, token, syms | |
14 | |
15 class FixRaise(fixer_base.BaseFix): | |
16 | |
17 PATTERN = u""" | |
18 raise_stmt< 'raise' (power< name=any [trailer< '(' val=any* ')' >] | |
19 [trailer< '.' 'with_traceback' > trailer< '(' trc=any ')' >] > | any) ['from' chain=any] >""" | |
20 | |
21 def transform(self, node, results): | |
22 FIXME | |
23 name, val, trc = (results.get(u"name"), results.get(u"val"), results.get(u"trc")) | |
24 chain = results.get(u"chain") | |
25 if chain is not None: | |
26 self.warning(node, u"explicit exception chaining is not supported in Python 2") | |
27 chain.prev_sibling.remove() | |
28 chain.remove() | |
29 if trc is not None: | |
30 val = val[0] if val else Leaf(token.NAME, u"None") | |
31 val.prefix = trc.prefix = u" " | |
32 kids = [Leaf(token.NAME, u"raise"), name.clone(), Comma(), | |
33 val.clone(), Comma(), trc.clone()] | |
34 raise_stmt = Node(syms.raise_stmt, kids) | |
35 node.replace(raise_stmt) |