def parse_args(args):
"""
Takes in the command-line arguments list (args), and returns a nice argparse
result with fields for all the options.
Borrows heavily from the argparse documentation examples:
<http://docs.python.org/library/argparse.html>
"""
# Construct the parser (which is stored in parser)
# Module docstring lives in __doc__
# See http://python-forum.com/pythonforum/viewtopic.php?f=3&t=36847
# And a formatter class so our examples in the docstring look good. Isn't it
# convenient how we already wrapped it to 80 characters?
# See http://docs.python.org/library/argparse.html#formatter-class
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
# Add the Toil options so the job store is the first argument
Job.Runner.addToilOptions(parser)
# General options
parser.add_argument("in_store", type=IOStore.absolute,
help="input IOStore to download from")
parser.add_argument("out_store", type=IOStore.absolute,
help="output IOStore to put things in")
parser.add_argument("--pattern", default="*",
help="fnmatch-style pattern for file names to copy")
parser.add_argument("--overwrite", default=False, action="store_true",
help="overwrite existing files")
parser.add_argument("--check_size", default=False, action="store_true",
help="check sizes on existing files and replace if wrong")
parser.add_argument("--batch_size", type=int, default=1000,
help="number of files to copy in a batch")
# The command line arguments start with the program name, which we don't
# want to treat as an argument for argparse. So we remove it.
args = args[1:]
return parser.parse_args(args)
评论列表
文章目录