Edgewall Software

source: tags/0.7.0/fixes/fix_unicode_in_strings.py

Last change on this file was 1154, checked in by hodgestar, 13 years ago

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)

  • Property svn:eol-style set to native
File size: 397 bytes
Line 
1"""Fixer that changes expressions inside strings literals from u"..." to "...".
2
3"""
4
5import re
6from lib2to3 import fixer_base
7
8_literal_re = re.compile(r"(.+?)\b[uU]([rR]?[\'\"])")
9
10class 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
Note: See TracBrowser for help on using the repository browser.