6363
6464from __future__ import (absolute_import , print_function , unicode_literals )
6565from future .builtins import *
66- from future import utils
66+ import future
67+ import future .utils
68+
69+ __version__ = '0.13.0-dev'
6770
6871import sys
6972import logging
8083
8184fixer_pkg = 'libfuturize.fixes'
8285
86+ if __version__ != future .__version__ :
87+ warn ('The libfuturize and future packages have different versions. '
88+ 'This may break the futurize script. Please ensure the versions '
89+ 'are consistent.' )
90+
8391
8492def main (args = None ):
8593 """Main program.
@@ -91,11 +99,13 @@ def main(args=None):
9199
92100 Returns a suggested exit status (0, 1, 2).
93101 """
94-
102+
95103 # Set up option parser
96104 parser = optparse .OptionParser (usage = "futurize [options] file|dir ..." )
105+ parser .add_option ("-V" , "--version" , action = "store_true" ,
106+ help = "Report the version number of futurize" )
97107 parser .add_option ("-a" , "--all-imports" , action = "store_true" ,
98- help = "Adds all __future__ and future imports to each module" )
108+ help = "Add all __future__ and future imports to each module" )
99109 parser .add_option ("-d" , "--doctests_only" , action = "store_true" ,
100110 help = "Fix up doctests only" )
101111 parser .add_option ("-1" , "--stage1" , action = "store_true" ,
@@ -136,11 +146,10 @@ def main(args=None):
136146 " Requires -n if non-empty. For Python >= 2.7 only."
137147 "ex: --add-suffix='3' will generate .py3 files." )
138148
139- avail_fixes = set ()
140-
141149 # Parse command line arguments
142150 refactor_stdin = False
143151 options , args = parser .parse_args (args )
152+
144153 if options .write_unchanged_files :
145154 flags ["write_unchanged_files" ] = True
146155 if not options .write :
@@ -175,6 +184,9 @@ def main(args=None):
175184 options .both_stages = False
176185 else :
177186 options .both_stages = True
187+
188+ avail_fixes = set ()
189+
178190 if options .stage1 or options .both_stages :
179191 avail_fixes .update (lib2to3_fix_names_stage1 )
180192 avail_fixes .update (libfuturize_fix_names_stage1 )
@@ -185,6 +197,9 @@ def main(args=None):
185197 if options .unicode_literals :
186198 avail_fixes .add ('libfuturize.fixes.fix_unicode_literals_import' )
187199
200+ if options .version :
201+ print (__version__ )
202+ return 0
188203 if options .list_fixes :
189204 print ("Available transformations for the -f/--fix option:" )
190205 # for fixname in sorted(refactor.get_all_fix_names(fixer_pkg)):
@@ -261,7 +276,7 @@ def main(args=None):
261276 options .output_dir , input_base_dir )
262277
263278 # Initialize the refactoring tool
264- if utils .PY26 :
279+ if future . utils .PY26 :
265280 extra_kwargs = {}
266281 else :
267282 extra_kwargs = {
0 commit comments