view fixes/fix_unicode_in_strings.py @ 998:44fb098722ac stable-0.7.x

Merge r1210 and r1212 from trunk (remove unnecessary isinstance checks and skip mako benchmarks if mako isn't installed).
author hodgestar
date Sat, 26 Jan 2013 17:34:51 +0000
parents d010a80ebb4f
children
line wrap: on
line source
"""Fixer that changes expressions inside strings literals from u"..." to "...".

"""

import re
from lib2to3 import fixer_base

_literal_re = re.compile(r"(.+?)\b[uU]([rR]?[\'\"])")

class FixUnicodeInStrings(fixer_base.BaseFix):

    PATTERN = "STRING"

    def transform(self, node, results):
        new = node.clone()
        new.value = _literal_re.sub(r"\1\2", new.value)
        return new
Copyright (C) 2012-2017 Edgewall Software