From 572f58c0a98c8a3efbcb82f300dd1dec35b9eb90 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 28 Sep 2022 05:33:09 +0200 Subject: [PATCH] Feat: add dest to on command --- pdf_oralia/extract.py | 4 ++-- pdf_oralia/scripts.py | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pdf_oralia/extract.py b/pdf_oralia/extract.py index 4435042..c8efd50 100644 --- a/pdf_oralia/extract.py +++ b/pdf_oralia/extract.py @@ -41,8 +41,8 @@ def extract_from_pdf(pdf, charge_dest, location_dest): def extract_save(pdf_file, dest): """Extract charge and locataire for pdf_file and put xlsx file in dest""" pdf_file = Path(pdf_file) - xls_charge = dest / f"{pdf_file.stem.replace(' ', '_')}_charge.xlsx" - xls_locataire = dest / f"{pdf_file.stem.replace(' ', '_')}_locataire.xlsx" + xls_charge = Path(dest) / f"{pdf_file.stem.replace(' ', '_')}_charge.xlsx" + xls_locataire = Path(dest) / f"{pdf_file.stem.replace(' ', '_')}_locataire.xlsx" pdf = pdfplumber.open(pdf_file) extract_from_pdf(pdf, xls_charge, xls_locataire) diff --git a/pdf_oralia/scripts.py b/pdf_oralia/scripts.py index 3543ba6..fe7dff9 100644 --- a/pdf_oralia/scripts.py +++ b/pdf_oralia/scripts.py @@ -17,11 +17,13 @@ def extract(): @extract.command() @click.argument("pdf_file", required=1) -def on(pdf_file): - pdf_path = Path(pdf_file) - pdf_filename = pdf_path.name - pdf_path = pdf_path.parent - extract_save(pdf_file, pdf_path) +@click.option("--dest", help="Où mettre les fichiers produits", default="") +def on(pdf_file, dest): + if not dest: + pdf_path = Path(pdf_file) + dest = pdf_path.parent + + extract_save(pdf_file, dest) @extract.command()