Feat: add dest to on command

This commit is contained in:
Bertrand Benjamin 2022-09-28 05:33:09 +02:00
parent b4e70f00fc
commit 572f58c0a9
2 changed files with 9 additions and 7 deletions

View File

@ -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)

View File

@ -17,11 +17,13 @@ def extract():
@extract.command()
@click.argument("pdf_file", required=1)
def on(pdf_file):
@click.option("--dest", help="Où mettre les fichiers produits", default="")
def on(pdf_file, dest):
if not dest:
pdf_path = Path(pdf_file)
pdf_filename = pdf_path.name
pdf_path = pdf_path.parent
extract_save(pdf_file, pdf_path)
dest = pdf_path.parent
extract_save(pdf_file, dest)
@extract.command()