Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../lib2to3/fixes
File: fix_methodattrs.py
"""Fix bound method attributes (method.im_? -> method.__?__).
[0] Fix | Delete
"""
[1] Fix | Delete
# Author: Christian Heimes
[2] Fix | Delete
[3] Fix | Delete
# Local imports
[4] Fix | Delete
from .. import fixer_base
[5] Fix | Delete
from ..fixer_util import Name
[6] Fix | Delete
[7] Fix | Delete
MAP = {
[8] Fix | Delete
"im_func" : "__func__",
[9] Fix | Delete
"im_self" : "__self__",
[10] Fix | Delete
"im_class" : "__self__.__class__"
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
class FixMethodattrs(fixer_base.BaseFix):
[14] Fix | Delete
BM_compatible = True
[15] Fix | Delete
PATTERN = """
[16] Fix | Delete
power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
[17] Fix | Delete
"""
[18] Fix | Delete
[19] Fix | Delete
def transform(self, node, results):
[20] Fix | Delete
attr = results["attr"][0]
[21] Fix | Delete
new = MAP[attr.value]
[22] Fix | Delete
attr.replace(Name(new, prefix=attr.prefix))
[23] Fix | Delete
[24] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function