Mercurial > genshi > mirror
annotate fixes/fix_unicode_in_strings.py @ 1011:d13802b8c7cc trunk
Updating upgrading document heading.
author | hodgestar |
---|---|
date | Thu, 21 Mar 2013 21:41:01 +0000 |
parents | d010a80ebb4f |
children |
rev | line source |
---|---|
929
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
1 """Fixer that changes expressions inside strings literals from u"..." to "...". |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
2 |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
3 """ |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
4 |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
5 import re |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
6 from lib2to3 import fixer_base |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
7 |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
8 _literal_re = re.compile(r"(.+?)\b[uU]([rR]?[\'\"])") |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
9 |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
10 class FixUnicodeInStrings(fixer_base.BaseFix): |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
11 |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
12 PATTERN = "STRING" |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
13 |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
14 def transform(self, node, results): |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
15 new = node.clone() |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
16 new.value = _literal_re.sub(r"\1\2", new.value) |
d010a80ebb4f
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)
hodgestar
parents:
diff
changeset
|
17 return new |