def main(): ns = parse_args() if ns.debug: level = logging.DEBUG elif ns.verbose: level = logging.INFO else: level = logging.ERROR logging.basicConfig(level=level) config_path = ns.config_path deterministic = ns.deterministic template_dir = ns.template_dir extra_template_dirs = ns.extra_template_dirs input_paths = ns.input_paths build_time = ns.build_time output_parent = ns.output_parent output_dir_name = ns.output_dir_name fresh_output = ns.output_fresh_parent test_mode = ns.test if build_time is not None: build_time = utils.parse_datetime(build_time) run(config_path=config_path, input_paths=input_paths, template_dir=template_dir, extra_template_dirs=extra_template_dirs, output_parent=output_parent, output_dir_name=output_dir_name, fresh_output=fresh_output, test_mode=test_mode, build_time=build_time, deterministic=deterministic)
def test_parse_datetime(self): cases = [ ('2018-06-01 20:48:12', datetime(2018, 6, 1, 20, 48, 12)), ] for dt_string, expected in cases: with self.subTest(dt_string=dt_string): actual = utils.parse_datetime(dt_string) self.assertEqual(actual, expected)
def parse_date_time(obj, dt_string): """ Remove and parse a date time from the given data. Args: dt_string: a datetime string in the format "2016-11-08 hh:mm:ss". """ _log.debug(f'processing parse_date_time: {dt_string}') dt = utils.parse_datetime(dt_string) return dt
def parse_common_args(ns, default_log_level=None): """ Return an OrrOptions object. """ if default_log_level is None: default_log_level = logging.ERROR build_time = ns.build_time input_data_dir = ns.input_dir input_results_dir = ns.input_results_dir output_parent = ns.output_parent output_subdir = ns.output_subdir template_dir = ns.template_dir extra_template_dirs = ns.extra_template_dirs deterministic = ns.deterministic skip_pdf = ns.skip_pdf if ns.debug: level = logging.DEBUG elif ns.verbose: level = logging.INFO else: level = default_log_level if build_time is None: build_time = datetime.now() else: build_time = utils.parse_datetime(build_time) if not input_data_dir: raise RuntimeError('--input-dir not provided') input_data_dir = Path(input_data_dir) if input_results_dir is not None: input_results_dir = Path(input_results_dir) if output_parent is None: output_parent = DEFAULT_OUTPUT_PARENT_DIR if output_subdir is None: output_subdir = generate_output_name(build_time) output_parent = Path(output_parent) output_dir = output_parent / output_subdir if extra_template_dirs is None: extra_template_dirs = [] extra_template_dirs = [Path(path) for path in extra_template_dirs] input_dirs = InputDirs(data_dir=input_data_dir, results_dir=input_results_dir, template_dir=template_dir, extra_template_dirs=extra_template_dirs) options = OrrOptions( input_dirs, output_dir=output_dir, build_time=build_time, log_level=level, deterministic=deterministic, skip_pdf=skip_pdf, ) return options