summaryrefslogtreecommitdiff
path: root/python/helpers/pydev/third_party/pep8/lib2to3/lib2to3/fixes/fix_methodattrs.py
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-09-04 20:44:00 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-09-04 20:44:01 +0000
commitfb5a02906f644d044eb0286bf27d413ba0e05216 (patch)
treebca7d49005d81d10c70bc3f547df041c636b4300 /python/helpers/pydev/third_party/pep8/lib2to3/lib2to3/fixes/fix_methodattrs.py
parent9cde0e3c015174898df8b8f3672185941fad4786 (diff)
parentd245f58efbfc26b13b9b9d5e52e6a83a0d76216c (diff)
downloadidea-fb5a02906f644d044eb0286bf27d413ba0e05216.tar.gz
Merge "Merge remote-tracking branch 'aosp/upstream-master' into merge"
Diffstat (limited to 'python/helpers/pydev/third_party/pep8/lib2to3/lib2to3/fixes/fix_methodattrs.py')
-rw-r--r--python/helpers/pydev/third_party/pep8/lib2to3/lib2to3/fixes/fix_methodattrs.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/python/helpers/pydev/third_party/pep8/lib2to3/lib2to3/fixes/fix_methodattrs.py b/python/helpers/pydev/third_party/pep8/lib2to3/lib2to3/fixes/fix_methodattrs.py
new file mode 100644
index 000000000000..f3c1ecfec153
--- /dev/null
+++ b/python/helpers/pydev/third_party/pep8/lib2to3/lib2to3/fixes/fix_methodattrs.py
@@ -0,0 +1,24 @@
+"""Fix bound method attributes (method.im_? -> method.__?__).
+"""
+# Author: Christian Heimes
+
+# Local imports
+from .. import fixer_base
+from ..fixer_util import Name
+
+MAP = {
+ "im_func" : "__func__",
+ "im_self" : "__self__",
+ "im_class" : "__self__.__class__"
+ }
+
+class FixMethodattrs(fixer_base.BaseFix):
+ BM_compatible = True
+ PATTERN = """
+ power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* >
+ """
+
+ def transform(self, node, results):
+ attr = results["attr"][0]
+ new = unicode(MAP[attr.value])
+ attr.replace(Name(new, prefix=attr.prefix))