You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
849 B
34 lines
849 B
import pathlib |
|
import warnings |
|
|
|
import click |
|
from PyPDFForm import PdfWrapper |
|
|
|
warnings.filterwarnings("ignore") |
|
|
|
WINHOME = pathlib.Path("/mnt/c/Users/Holgi/") |
|
DESKTOP = WINHOME / "Desktop" |
|
|
|
|
|
@click.command() |
|
@click.argument( |
|
"form", type=click.Path(exists=True, file_okay=True, dir_okay=False) |
|
) |
|
@click.option( |
|
"-o", |
|
"--output", |
|
default=None, |
|
help="Output file path, defaults to desktop folder", |
|
) |
|
def inspect(form, output): |
|
path = pathlib.Path(form) |
|
if not output: |
|
new_name = f"inspecting {path.name}" |
|
output = DESKTOP / new_name |
|
form = PdfWrapper(str(path)) |
|
inspection_result = form.schema |
|
data = {k:k for k in inspection_result["properties"]} |
|
filled = form.fill(data) |
|
filled.write(output) |
|
#with output.open("wb+") as output_stream: |
|
# output_stream.write(preview_stream)
|
|
|