From 1383951191f662056fb0cd5a4fab5aa3b5ab6654 Mon Sep 17 00:00:00 2001 From: Tilman Kamp <5991088+tilmankamp@users.noreply.github.com> Date: Mon, 17 Feb 2020 12:34:56 +0100 Subject: [PATCH] Fix --no-progress option; better info logs --- align/export.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/align/export.py b/align/export.py index c5920f3..01c6415 100644 --- a/align/export.py +++ b/align/export.py @@ -187,8 +187,11 @@ def main(args): logging.getLogger('sox').setLevel(logging.ERROR) def progress(it=None, desc='Processing', total=None): - desc = desc.rjust(30) - return iter if args.no_progress else tqdm(it, desc=desc, total=total, ncols=120) + if args.no_progress: + logging.info(desc) + return it + else: + return tqdm(it, desc=desc.rjust(30), total=total, ncols=120) logging.debug("Start") @@ -454,10 +457,15 @@ def main(args): for list_name, sdb in lists.items(): meta_path = os.path.join(target_dir, list_name + '.meta') if not dry_run: - with progress(desc='Finalizing {}'.format(list_name), total=1000) as bar: - for frac in sdb.finalize(): - bar.n = int(frac * 1001) - bar.refresh() + if args.no_progress: + logging.info('Finalizing {}'.format(list_name)) + sdb.close() + else: + with progress(desc='Finalizing {}'.format(list_name), total=1000) as bar: + for frac in sdb.finalize(): + bar.n = int(frac * 1001) + bar.refresh() + logging.info('Writing meta file "{}"'.format(meta_path)) with open(meta_path, 'w') as meta_file: json.dump(sdb.meta_dict, meta_file) else: