2022-09-27 12:48:41 +00:00
|
|
|
from pathlib import Path
|
2022-09-27 13:01:14 +00:00
|
|
|
|
2022-09-27 12:48:41 +00:00
|
|
|
import click
|
|
|
|
|
2022-09-27 14:01:09 +00:00
|
|
|
from .extract import extract_save
|
2022-09-27 12:48:41 +00:00
|
|
|
|
|
|
|
|
2022-09-27 14:01:09 +00:00
|
|
|
@click.group()
|
|
|
|
def main():
|
|
|
|
pass
|
2022-09-27 12:48:41 +00:00
|
|
|
|
|
|
|
|
2022-09-27 14:01:09 +00:00
|
|
|
@main.group()
|
|
|
|
def extract():
|
|
|
|
pass
|
2022-09-27 12:48:41 +00:00
|
|
|
|
|
|
|
|
2022-09-27 14:01:09 +00:00
|
|
|
@extract.command()
|
2022-09-27 18:45:26 +00:00
|
|
|
@click.argument("pdf_file", help="Nom du fichier pdf")
|
|
|
|
def on(pdf_file):
|
2022-09-27 14:01:09 +00:00
|
|
|
extract_save(pdf_file)
|
2022-09-27 12:48:41 +00:00
|
|
|
|
|
|
|
|
2022-09-27 14:01:09 +00:00
|
|
|
@extract.command()
|
|
|
|
@click.option("--folder", help="Tous les fichiers dans folder", default="./")
|
|
|
|
@click.option("--dest", help="Où mettre les fichiers produits", default="./")
|
|
|
|
def all(folder, dest):
|
|
|
|
p = Path(folder)
|
2022-09-27 12:48:41 +00:00
|
|
|
|
2022-09-27 14:01:09 +00:00
|
|
|
d = Path(dest)
|
|
|
|
d.mkdir(exist_ok=True)
|
2022-09-27 13:01:14 +00:00
|
|
|
|
2022-09-27 14:01:09 +00:00
|
|
|
pdf_files = [x for x in p.iterdir() if ".pdf" in str(x)]
|
|
|
|
for pdf_file in pdf_files:
|
|
|
|
extract_save(pdf_file, d)
|
2022-09-27 12:48:41 +00:00
|
|
|
|
|
|
|
|
2022-09-27 14:01:09 +00:00
|
|
|
@main.command()
|
|
|
|
def join():
|
|
|
|
pass
|