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

Side by Side Diff: third_party/google-endpoints/libpasteurize/fixes/fix_throw.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 'g.throw(E(V).with_traceback(T))' -> 'g.throw(E, V, T)'"""
2
3 from lib2to3 import fixer_base
4 from lib2to3.pytree import Node, Leaf
5 from lib2to3.pgen2 import token
6 from lib2to3.fixer_util import Comma
7
8 class FixThrow(fixer_base.BaseFix):
9
10 PATTERN = u"""
11 power< any trailer< '.' 'throw' >
12 trailer< '(' args=power< exc=any trailer< '(' val=any* ')' >
13 trailer< '.' 'with_traceback' > trailer< '(' trc=any ')' > > ')' > >
14 """
15
16 def transform(self, node, results):
17 syms = self.syms
18 exc, val, trc = (results[u"exc"], results[u"val"], results[u"trc"])
19 val = val[0] if val else Leaf(token.NAME, u"None")
20 val.prefix = trc.prefix = u" "
21 kids = [exc.clone(), Comma(), val.clone(), Comma(), trc.clone()]
22 args = results[u"args"]
23 args.children = kids
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698