]> git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/lib2to3/fixes/fix_unicode.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / lib2to3 / fixes / fix_unicode.py
1 """Fixer that changes unicode to str, unichr to chr, and u"..." into "...".
2
3 """
4
5 import re
6 from ..pgen2 import token
7 from .. import fixer_base
8
9 _mapping = {u"unichr" : u"chr", u"unicode" : u"str"}
10 _literal_re = re.compile(ur"[uU][rR]?[\'\"]")
11
12 class FixUnicode(fixer_base.BaseFix):
13 BM_compatible = True
14 PATTERN = "STRING | 'unicode' | 'unichr'"
15
16 def transform(self, node, results):
17 if node.type == token.NAME:
18 new = node.clone()
19 new.value = _mapping[node.value]
20 return new
21 elif node.type == token.STRING:
22 if _literal_re.match(node.value):
23 new = node.clone()
24 new.value = new.value[1:]
25 return new