symbian-qemu-0.9.1-12/python-win32-2.6.1/lib/lib2to3/fixes/fix_funcattrs.py
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 """Fix function attribute names (f.func_x -> f.__x__)."""
       
     2 # Author: Collin Winter
       
     3 
       
     4 # Local imports
       
     5 from .. import fixer_base
       
     6 from ..fixer_util import Name
       
     7 
       
     8 
       
     9 class FixFuncattrs(fixer_base.BaseFix):
       
    10     PATTERN = """
       
    11     power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals'
       
    12                                   | 'func_name' | 'func_defaults' | 'func_code'
       
    13                                   | 'func_dict') > any* >
       
    14     """
       
    15 
       
    16     def transform(self, node, results):
       
    17         attr = results["attr"][0]
       
    18         attr.replace(Name(("__%s__" % attr.value[5:]),
       
    19                           prefix=attr.get_prefix()))