Mercurial > genshi > genshi-test
view fixes/fix_unicode_in_strings.py @ 920:f4bf11c716cc experimental-py3k
Fix handling of QNames with leading open curly braces. See Genshi ticket #413.
author | hodgestar |
---|---|
date | Mon, 29 Nov 2010 20:20:56 +0000 |
parents | 46db99909472 |
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