Skip to content

Commit

Permalink
Merge pull request #443 from chinapandaman/PPF-442
Browse files Browse the repository at this point in the history
PPF-442: refine diff script
  • Loading branch information
chinapandaman authored Jan 15, 2024
2 parents 94fa629 + 6cd3502 commit 0403846
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion scripts/create_compare.py → scripts/create_pdf_diff.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 16 additions & 0 deletions scripts/open_pdf_diff.py
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 9 additions & 1 deletion scripts/create_compare.sh → scripts/pdf_diffs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0403846

Please sign in to comment.