def prepare_input(argv=None):
"""
Get, parse and prepare input file.
"""
p = ArgumentParser(description='InsiliChem Ommprotocol: '
'easy to deploy MD protocols for OpenMM')
p.add_argument('input', metavar='INPUT FILE', type=extant_file,
help='YAML input file')
p.add_argument('--version', action='version', version='%(prog)s v{}'.format(__version__))
p.add_argument('-c', '--check', action='store_true',
help='Validate input file only')
args = p.parse_args(argv if argv else sys.argv[1:])
# Load config file
with open(args.input) as f:
cfg = yaml.load(f, Loader=YamlLoader)
# Paths and dirs
cfg['_path'] = os.path.abspath(args.input)
cfg['system_options'] = prepare_system_options(cfg)
cfg['outputpath'] = sanitize_path_for_file(cfg.get('outputpath', '.'), args.input)
if not args.check:
with ignored_exceptions(OSError):
os.makedirs(cfg['outputpath'])
handler = prepare_handler(cfg)
return handler, cfg, args
评论列表
文章目录