From 6e93f85fe2eba5ad1bb6add3d303334840d1350e Mon Sep 17 00:00:00 2001 From: Amandine PERRIN <amandine.perrin@pasteur.fr> Date: Wed, 14 Oct 2020 11:58:24 +0200 Subject: [PATCH] Use utils argparse checking instead of a local one --- PanACoTA/subcommands/align.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/PanACoTA/subcommands/align.py b/PanACoTA/subcommands/align.py index 315882b6..0000d3f6 100755 --- a/PanACoTA/subcommands/align.py +++ b/PanACoTA/subcommands/align.py @@ -157,25 +157,7 @@ def build_parser(parser): """ import argparse import multiprocessing - - def thread_num(param): - try: - param = int(param) - except Exception: - msg = "argument --threads threads: invalid int value: {}".format(param) - raise argparse.ArgumentTypeError(msg) - nb_cpu = multiprocessing.cpu_count() - if param > nb_cpu: - msg = ("You have {} threads on your computer, you cannot ask for more: " - "invalid value: {}").format(nb_cpu, param) - raise argparse.ArgumentTypeError(msg) - elif param < 0: - msg = ("Please provide a positive number of threads (or 0 for all threads): " - "Invalid value: {}").format(param) - raise argparse.ArgumentTypeError(msg) - elif param == 0: - return nb_cpu - return param + from PanACoTA import utils_argparse # Create command-line parser for all options and arguments to give required = parser.add_argument_group('Required arguments') @@ -200,7 +182,7 @@ def build_parser(parser): help="Output directory, where all results must be saved ") optional = parser.add_argument_group('Optional arguments') - optional.add_argument("--threads", dest="threads", default=1, type=thread_num, + optional.add_argument("--threads", dest="threads", default=1, type=utils_argparse.thread_num, help=("add this option if you want to parallelize on several threads. " "Indicate on how many threads you want to parallelize. " "By default, it uses 1 thread. Put 0 if you want to use " -- GitLab