Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: third_party/google-endpoints/libpasteurize/fixes/fix_raise_.py

Issue 2666783008: Add google-endpoints to third_party/. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698