igor.script: Replace ArgumentParser(version=...) with a version argument
authorW. Trevor King <wking@tremily.us>
Tue, 2 Aug 2016 04:02:50 +0000 (21:02 -0700)
committerW. Trevor King <wking@tremily.us>
Tue, 2 Aug 2016 04:23:28 +0000 (21:23 -0700)
ArgumentParser lost its undocumented version argument in 3.3.0
[1,2,3].  The version action is the documented way to do this [4].

[1]: http://bugs.python.org/issue13248
[2]: https://hg.python.org/cpython/rev/5393382c1b1d
[3]: https://hg.python.org/cpython/file/374f501f4567/Misc/HISTORY#l477
[4]: https://docs.python.org/3/library/argparse.html#action

igor/script.py

index acb1a22..685fdd1 100644 (file)
@@ -36,8 +36,10 @@ class Script (object):
     log_levels = [_logging.ERROR, _logging.WARNING, _logging.INFO, _logging.DEBUG]
 
     def __init__(self, description=None, filetype='IGOR Binary Wave (.ibw) file'):
-        self.parser = _argparse.ArgumentParser(
-            description=description, version=__version__)
+        self.parser = _argparse.ArgumentParser(description=description)
+        self.parser.add_argument(
+            '--version', action='version',
+            version='%(prog)s {}'.format(__version__))
         self.parser.add_argument(
             '-f', '--infile', metavar='FILE', default='-',
             help='input {}'.format(filetype))