From eafd3327dc2e18f4368d255546d610a66db6da03 Mon Sep 17 00:00:00 2001 From: Yannick Ulrich <yannick.ulrich@psi.ch> Date: Fri, 21 Feb 2020 12:32:12 +0100 Subject: [PATCH] Split parsing function (#6) --- pymule/__main__.py | 3 +++ pymule/createrun.py | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pymule/__main__.py b/pymule/__main__.py index ba3d4f3..0e02366 100644 --- a/pymule/__main__.py +++ b/pymule/__main__.py @@ -1,8 +1,11 @@ import argparse +import createrun if __name__ == '__main__': parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() + createrun.create_parser(subparsers) + parsed = parser.parse_args() diff --git a/pymule/createrun.py b/pymule/createrun.py index 8c46bb1..f97e33c 100644 --- a/pymule/createrun.py +++ b/pymule/createrun.py @@ -223,11 +223,12 @@ def interogate(args={}): return args -def parseargs(): +def create_parser(subparsers): specs = inspect.getargspec(create_menu) defaults = dict(zip(specs.args, specs.defaults)) - parser = argparse.ArgumentParser( + parser = subparsers.add_parser( + 'create', description='Generate menu and config files' ) parser.add_argument( @@ -274,7 +275,8 @@ def parseargs(): help="comma seperated list of piece,pc,pi,c,i[,seeds to use]" ) - parsed = parser.parse_args() + +def parseargs(parsed): args = {} if parsed.nseeds: @@ -360,8 +362,7 @@ def save(menu, conf, folder, force=False): print "Please change the ntasks and time options accordingly" -if __name__ == '__main__': - import sys - args, force = parseargs() +def main(parsed): + args, force = parseargs(parsed) menu, config, folder = create_menu(**args) save(menu, config, folder, force=force) -- GitLab