annotate Lib/lib2to3/fixes/fix_future.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents b36cb4602e21
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
58737
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
1 """Remove __future__ imports
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
2
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
3 from __future__ import foo is replaced with an empty line.
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
4 """
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
5 # Author: Christian Heimes
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
6
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
7 # Local imports
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
8 from .. import fixer_base
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
9 from ..fixer_util import BlankLine
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
10
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
11 class FixFuture(fixer_base.BaseFix):
65340
7d1e453b120b Merged revisions 83852-83853,83857,84042,84216,84274-84276,84375,85388,85478,85506-85508 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 54709
diff changeset
12 BM_compatible = True
7d1e453b120b Merged revisions 83852-83853,83857,84042,84216,84274-84276,84375,85388,85478,85506-85508 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 54709
diff changeset
13
58737
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
14 PATTERN = """import_from< 'from' module_name="__future__" 'import' any >"""
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
15
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
16 # This should be run last -- some things check for the import
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
17 run_order = 10
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
18
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
19 def transform(self, node, results):
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
20 new = BlankLine()
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
21 new.prefix = node.prefix
fab380674959 copy lib2to3 from the trunk
Benjamin Peterson <benjamin@python.org>
parents:
diff changeset
22 return new