|
36 | 36 | import sys |
37 | 37 | import logging |
38 | 38 | import optparse |
39 | | - |
40 | 39 | from lib2to3.main import main, warn, StdoutRefactoringTool |
41 | 40 | from lib2to3 import refactor |
42 | 41 |
|
| 42 | +import future |
43 | 43 | from libpasteurize.fixes import fix_names |
44 | 44 |
|
| 45 | +__version__ = '0.12.3-dev' |
| 46 | + |
| 47 | +if __version__ != future.__version__: |
| 48 | + warn('The libfuturize and future packages have different versions. ' |
| 49 | + 'This may break the pasteurize script. Please ensure the versions ' |
| 50 | + 'are consistent.') |
| 51 | + |
| 52 | + |
45 | 53 |
|
46 | 54 | def main(args=None): |
47 | 55 | """Main program. |
48 | 56 |
|
49 | 57 | Returns a suggested exit status (0, 1, 2). |
50 | 58 | """ |
51 | 59 | # Set up option parser |
52 | | - parser = optparse.OptionParser(usage="futurize [options] file|dir ...") |
| 60 | + parser = optparse.OptionParser(usage="pasteurize [options] file|dir ...") |
| 61 | + parser.add_option("-V", "--version", action="store_true", |
| 62 | + help="Report the version number of pasteurize") |
53 | 63 | parser.add_option("-a", "--all-imports", action="store_true", |
54 | 64 | help="Adds all __future__ and future imports to each module") |
55 | 65 | parser.add_option("-d", "--doctests_only", action="store_true", |
@@ -85,6 +95,9 @@ def main(args=None): |
85 | 95 | warn("not writing files and not printing diffs; that's not very useful") |
86 | 96 | if not options.write and options.nobackups: |
87 | 97 | parser.error("Can't use -n without -w") |
| 98 | + if options.version: |
| 99 | + print(__version__) |
| 100 | + return 0 |
88 | 101 | if options.list_fixes: |
89 | 102 | print("Available transformations for the -f/--fix option:") |
90 | 103 | for fixname in sorted(avail_fixes): |
|
0 commit comments