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,
)
subparsers = parser.add_subparsers(
description="",
dest="command",
)
subparsers = parser.add_subparsers()
subparsers.required = True
clean = subparsers.add_parser(

11
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)
if __name__ == "__main__":
main(sys.argv)

Loading…
Cancel
Save