logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

fix_funcattrs.py (644B)


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