view fixes/fix_unicode_in_strings.py @ 1016:38565f2ab970 trunk

Fix handling of case where a translation has text after a closing tag (fixes #566, thanks to jomae for the patch).
author hodgestar
date Thu, 09 Jan 2014 21:23:41 +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