Changeset 9cf6462


Ignore:
Timestamp:
Oct 29, 2018, 8:30:34 PM (11 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
5332c29
Parents:
31a3fd4 (diff), eb6f9d3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'fix/py2cmd'

Location:
python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/cmd.py

    r31a3fd4 r9cf6462  
    500500def main():
    501501    parser = aubio_parser()
    502     args = parser.parse_args()
     502    if sys.version_info[0] != 3:
     503        # on py2, create a dummy ArgumentParser to workaround the
     504        # optional subcommand issue. See https://bugs.python.org/issue9253
     505        # This ensures that:
     506        #  - version string is shown when only '-V' is passed
     507        #  - help is printed if  '-V' is passed with any other argument
     508        #  - any other argument get forwarded to the real parser
     509        parser_root = argparse.ArgumentParser(add_help=False)
     510        parser_root.add_argument('-V', '--version', help="show version",
     511                action="store_true", dest="show_version")
     512        args, extras = parser_root.parse_known_args()
     513        if args.show_version == False: # no -V, forward to parser
     514            args = parser.parse_args(extras, namespace=args)
     515        elif len(extras) != 0: # -V with other arguments, print help
     516            parser.print_help()
     517            sys.exit(1)
     518    else: # in py3, we can simply use parser directly
     519        args = parser.parse_args()
    503520    if 'show_version' in args and args.show_version:
    504521        sys.stdout.write('aubio version ' + aubio.version + '\n')
  • python/tests/test_aubio_cmd.py

    r31a3fd4 r9cf6462  
    2020
    2121    def test_samples2seconds(self):
    22         self.assertEqual(aubio.cmd.samples2seconds(3200, 32000), "0.100000\t")
     22        self.assertEqual(aubio.cmd.samples2seconds(3200, 32000),
     23                "0.100000\t")
    2324
    2425    def test_samples2milliseconds(self):
    25         self.assertEqual(aubio.cmd.samples2milliseconds(3200, 32000), "100.000000\t")
     26        self.assertEqual(aubio.cmd.samples2milliseconds(3200, 32000),
     27                "100.000000\t")
    2628
    2729    def test_samples2samples(self):
    28         self.assertEqual(aubio.cmd.samples2samples(3200, 32000), "3200\t")
     30        self.assertEqual(aubio.cmd.samples2samples(3200, 32000),
     31                "3200\t")
    2932
    3033if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.