Mercurial > genshi > mirror
comparison fixes/fix_unicode_in_strings.py @ 929:d010a80ebb4f trunk
Merge r1137 from py3k: add 2to3 build infrastructure to setup.py (this pulls the tests into the source distribution so that tests can be run after building with 2to3)
author | hodgestar |
---|---|
date | Fri, 18 Mar 2011 09:02:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
925:8e8372810ff4 | 929:d010a80ebb4f |
---|---|
1 """Fixer that changes expressions inside strings literals from u"..." to "...". | |
2 | |
3 """ | |
4 | |
5 import re | |
6 from lib2to3 import fixer_base | |
7 | |
8 _literal_re = re.compile(r"(.+?)\b[uU]([rR]?[\'\"])") | |
9 | |
10 class FixUnicodeInStrings(fixer_base.BaseFix): | |
11 | |
12 PATTERN = "STRING" | |
13 | |
14 def transform(self, node, results): | |
15 new = node.clone() | |
16 new.value = _literal_re.sub(r"\1\2", new.value) | |
17 return new |