From 6fb11cb0545f04643b2f0e53d2b7d8980981d12b Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Tue, 24 Sep 2019 15:41:57 +0200 Subject: [PATCH] Feat: report a csv file, a directory or all --- recopytex/scripts/recopytex.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/recopytex/scripts/recopytex.py b/recopytex/scripts/recopytex.py index dbfa045..fc8ab11 100644 --- a/recopytex/scripts/recopytex.py +++ b/recopytex/scripts/recopytex.py @@ -55,18 +55,25 @@ def reporting(csv_file): ) @cli.command() -@click.argument("csv_file", required=False) -def report(csv_file=""): - if csv_file: - csv = Path(csv_file) - if not csv.exists(): - click.echo(f"{csv_file} does not exists") - sys.exit(1) - if csv.suffix != ".csv": - click.echo(f"{csv_file} has to be a csv file") - sys.exit(1) - csvs = [csv] - else: +@click.argument("target", required=False) +def report(target=""): + """ Make a report for the eval + + :param target: csv file or a directory where csvs are + """ + try: + if target.endswith(".csv"): + csv = Path(target) + if not csv.exists(): + click.echo(f"{target} does not exists") + sys.exit(1) + if csv.suffix != ".csv": + click.echo(f"{target} has to be a csv file") + sys.exit(1) + csvs = [csv] + else: + csvs = list(Path(target).glob('**/*.csv')) + except AttributeError: csvs = list(Path(config["source"]).glob('**/*.csv')) for csv in csvs: