Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python2..../lib2to3/fixes
File: fix_unicode.py
r"""Fixer for unicode.
[0] Fix | Delete
[1] Fix | Delete
* Changes unicode to str and unichr to chr.
[2] Fix | Delete
[3] Fix | Delete
* If "...\u..." is not unicode literal change it into "...\\u...".
[4] Fix | Delete
[5] Fix | Delete
* Change u"..." into "...".
[6] Fix | Delete
[7] Fix | Delete
"""
[8] Fix | Delete
[9] Fix | Delete
from ..pgen2 import token
[10] Fix | Delete
from .. import fixer_base
[11] Fix | Delete
[12] Fix | Delete
_mapping = {u"unichr" : u"chr", u"unicode" : u"str"}
[13] Fix | Delete
[14] Fix | Delete
class FixUnicode(fixer_base.BaseFix):
[15] Fix | Delete
BM_compatible = True
[16] Fix | Delete
PATTERN = "STRING | 'unicode' | 'unichr'"
[17] Fix | Delete
[18] Fix | Delete
def start_tree(self, tree, filename):
[19] Fix | Delete
super(FixUnicode, self).start_tree(tree, filename)
[20] Fix | Delete
self.unicode_literals = 'unicode_literals' in tree.future_features
[21] Fix | Delete
[22] Fix | Delete
def transform(self, node, results):
[23] Fix | Delete
if node.type == token.NAME:
[24] Fix | Delete
new = node.clone()
[25] Fix | Delete
new.value = _mapping[node.value]
[26] Fix | Delete
return new
[27] Fix | Delete
elif node.type == token.STRING:
[28] Fix | Delete
val = node.value
[29] Fix | Delete
if not self.unicode_literals and val[0] in u'\'"' and u'\\' in val:
[30] Fix | Delete
val = ur'\\'.join([
[31] Fix | Delete
v.replace(u'\\u', ur'\\u').replace(u'\\U', ur'\\U')
[32] Fix | Delete
for v in val.split(ur'\\')
[33] Fix | Delete
])
[34] Fix | Delete
if val[0] in u'uU':
[35] Fix | Delete
val = val[1:]
[36] Fix | Delete
if val == node.value:
[37] Fix | Delete
return node
[38] Fix | Delete
new = node.clone()
[39] Fix | Delete
new.value = val
[40] Fix | Delete
return new
[41] Fix | Delete
[42] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function