1 | n/a | """Fix function attribute names (f.func_x -> f.__x__).""" |
---|
2 | n/a | # Author: Collin Winter |
---|
3 | n/a | |
---|
4 | n/a | # Local imports |
---|
5 | n/a | from .. import fixer_base |
---|
6 | n/a | from ..fixer_util import Name |
---|
7 | n/a | |
---|
8 | n/a | |
---|
9 | n/a | class FixFuncattrs(fixer_base.BaseFix): |
---|
10 | n/a | BM_compatible = True |
---|
11 | n/a | |
---|
12 | n/a | PATTERN = """ |
---|
13 | n/a | power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals' |
---|
14 | n/a | | 'func_name' | 'func_defaults' | 'func_code' |
---|
15 | n/a | | 'func_dict') > any* > |
---|
16 | n/a | """ |
---|
17 | n/a | |
---|
18 | n/a | def transform(self, node, results): |
---|
19 | n/a | attr = results["attr"][0] |
---|
20 | n/a | attr.replace(Name(("__%s__" % attr.value[5:]), |
---|
21 | n/a | prefix=attr.prefix)) |
---|