/Lib/lib2to3/fixes/fix_future.py

http://unladen-swallow.googlecode.com/ · Python · 20 lines · 9 code · 4 blank · 7 comment · 0 complexity · 0e2786c94aac6b11a47d8ec46d8b19d6 MD5 · raw file

  1. """Remove __future__ imports
  2. from __future__ import foo is replaced with an empty line.
  3. """
  4. # Author: Christian Heimes
  5. # Local imports
  6. from .. import fixer_base
  7. from ..fixer_util import BlankLine
  8. class FixFuture(fixer_base.BaseFix):
  9. PATTERN = """import_from< 'from' module_name="__future__" 'import' any >"""
  10. # This should be run last -- some things check for the import
  11. run_order = 10
  12. def transform(self, node, results):
  13. new = BlankLine()
  14. new.prefix = node.get_prefix()
  15. return new