import hashlib import os import tarfile import urllib.request from tqdm import tqdm def print_arguments(args): print("----------- Configuration Arguments -----------") for arg, value in vars(args).items(): print("%s: %s" % (arg, value)) print("------------------------------------------------") def strtobool(val): val = val.lower() if val in ('y', 'yes', 't', 'true', 'on', '1'): return True elif val in ('n', 'no', 'f', 'false', 'off', '0'): return False else: raise ValueError("invalid truth value %r" % (val,)) def str_none(val): if val == 'None': return None else: return val def add_arguments(argname, type, default, help, argparser, **kwargs): type = strtobool if type == bool else type type = str_none if type == str else type argparser.add_argument("--" + argname, default=default, type=type, help=help + ' Default: %(default)s.', **kwargs)