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

Side by Side Diff: third_party/google-endpoints/libfuturize/fixes/fix_unicode_keep_u.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 """Fixer that changes unicode to str and unichr to chr, but -- unlike the
2 lib2to3 fix_unicode.py fixer, does not change u"..." into "...".
3
4 The reason is that Py3.3+ supports the u"..." string prefix, and, if
5 present, the prefix may provide useful information for disambiguating
6 between byte strings and unicode strings, which is often the hardest part
7 of the porting task.
8
9 """
10
11 from lib2to3.pgen2 import token
12 from lib2to3 import fixer_base
13
14 _mapping = {u"unichr" : u"chr", u"unicode" : u"str"}
15
16 class FixUnicodeKeepU(fixer_base.BaseFix):
17 BM_compatible = True
18 PATTERN = "'unicode' | 'unichr'"
19
20 def transform(self, node, results):
21 if node.type == token.NAME:
22 new = node.clone()
23 new.value = _mapping[node.value]
24 return new
25
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698