diff --git a/Makefile b/Makefile index 562bdce9..24acc1af 100644 --- a/Makefile +++ b/Makefile @@ -13,5 +13,5 @@ check-imports: generate-new-pdf-samples: bash ./scripts/new_pdf_samples.sh -compare-pdf-samples: - bash ./scripts/create_compare.sh +compare-pdf-diffs: + bash ./scripts/pdf_diffs.sh diff --git a/scripts/create_compare.py b/scripts/create_pdf_diff.py similarity index 88% rename from scripts/create_compare.py rename to scripts/create_pdf_diff.py index 4d387286..99c0975d 100644 --- a/scripts/create_compare.py +++ b/scripts/create_pdf_diff.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Creates compare of PDFs between changes.""" +"""Creates a diff of a PDF between changes.""" import os import sys diff --git a/scripts/open_pdf_diff.py b/scripts/open_pdf_diff.py new file mode 100644 index 00000000..8ea97bd4 --- /dev/null +++ b/scripts/open_pdf_diff.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +"""Opens a diff of a PDF between changes.""" + +import os +import sys +import webbrowser + +if __name__ == "__main__": + before_path = sys.argv[1] + file_name = os.path.basename(os.path.abspath(before_path)) + after_path = os.path.join(os.path.dirname(__file__), "..", "temp", file_name) + + webbrowser.get("/usr/bin/google-chrome %s").open(before_path) + webbrowser.get("/usr/bin/google-chrome %s").open(after_path) + + print("Checking", before_path) diff --git a/scripts/create_compare.sh b/scripts/pdf_diffs.sh similarity index 51% rename from scripts/create_compare.sh rename to scripts/pdf_diffs.sh index c3a928b7..0affeb47 100644 --- a/scripts/create_compare.sh +++ b/scripts/pdf_diffs.sh @@ -4,8 +4,16 @@ fi pytest -v -s --regenerate=1 +BEFORE=() + for f in $(git diff --name-only ./pdf_samples); do - python ./scripts/create_compare.py "$PWD/${f}" + BEFORE+=("$PWD/${f}") + python ./scripts/create_pdf_diff.py "$PWD/${f}" done git restore --source=HEAD --staged --worktree -- ./pdf_samples + +for i in "${BEFORE[@]}"; do + python ./scripts/open_pdf_diff.py "$i" + read -p "Press any key to continue..." -n1 -s -r +done