Browse Source

minor simplifications

pull/232/head
Oliverpool 9 years ago
parent
commit
be3827ae8d
  1. 5
      patacrep/tools/cache/__main__.py
  2. 11
      patacrep/tools/content/__main__.py

5
patacrep/tools/cache/__main__.py

@ -22,10 +22,7 @@ def commandline_parser():
formatter_class=argparse.RawTextHelpFormatter, formatter_class=argparse.RawTextHelpFormatter,
) )
subparsers = parser.add_subparsers( subparsers = parser.add_subparsers()
description="",
dest="command",
)
subparsers.required = True subparsers.required = True
clean = subparsers.add_parser( clean = subparsers.add_parser(

11
patacrep/tools/content/__main__.py

@ -23,10 +23,7 @@ def commandline_parser():
formatter_class=argparse.RawTextHelpFormatter, formatter_class=argparse.RawTextHelpFormatter,
) )
subparsers = parser.add_subparsers( subparsers = parser.add_subparsers()
description="",
dest="command",
)
subparsers.required = True subparsers.required = True
content_items = subparsers.add_parser( content_items = subparsers.add_parser(
@ -57,7 +54,7 @@ def do_content_items(namespace):
normalize_song_path(item.file_entry(), ref_dir) normalize_song_path(item.file_entry(), ref_dir)
for item in content_items 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): def normalize_song_path(file_entry, ref_dir):
"""Normalize the 'song' value, relative to 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): def main(args):
"""Main function: run from command line.""" """Main function: run from command line."""
options = commandline_parser().parse_args(args[1:]) options = commandline_parser().parse_args(args[1:])
try:
options.command(options) options.command(options)
except errors.SongbookError as error:
LOGGER.error(str(error))
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv) main(sys.argv)

Loading…
Cancel
Save