From be3827ae8d1c84a5e34fc37e3a93b57d0b55292f Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Wed, 20 Jul 2016 15:53:19 +0200 Subject: [PATCH] minor simplifications --- patacrep/tools/cache/__main__.py | 5 +---- patacrep/tools/content/__main__.py | 13 +++---------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/patacrep/tools/cache/__main__.py b/patacrep/tools/cache/__main__.py index e5aada68..6faf7989 100644 --- a/patacrep/tools/cache/__main__.py +++ b/patacrep/tools/cache/__main__.py @@ -22,10 +22,7 @@ def commandline_parser(): formatter_class=argparse.RawTextHelpFormatter, ) - subparsers = parser.add_subparsers( - description="", - dest="command", - ) + subparsers = parser.add_subparsers() subparsers.required = True clean = subparsers.add_parser( diff --git a/patacrep/tools/content/__main__.py b/patacrep/tools/content/__main__.py index 0f040e38..67d6b1de 100644 --- a/patacrep/tools/content/__main__.py +++ b/patacrep/tools/content/__main__.py @@ -23,10 +23,7 @@ def commandline_parser(): formatter_class=argparse.RawTextHelpFormatter, ) - subparsers = parser.add_subparsers( - description="", - dest="command", - ) + subparsers = parser.add_subparsers() subparsers.required = True content_items = subparsers.add_parser( @@ -57,7 +54,7 @@ def do_content_items(namespace): normalize_song_path(item.file_entry(), ref_dir) for item in content_items ] - print(yaml.safe_dump(content_items, allow_unicode=True, default_flow_style=False)) + sys.stdout.write(yaml.safe_dump(content_items, allow_unicode=True, default_flow_style=False)) def normalize_song_path(file_entry, ref_dir): """Normalize the 'song' value, relative to ref_dir""" @@ -68,11 +65,7 @@ def normalize_song_path(file_entry, ref_dir): def main(args): """Main function: run from command line.""" options = commandline_parser().parse_args(args[1:]) - try: - options.command(options) - except errors.SongbookError as error: - LOGGER.error(str(error)) - sys.exit(1) + options.command(options) if __name__ == "__main__": main(sys.argv)