From ee17c7ca7609159fb1e925d57cabd229a400dacc Mon Sep 17 00:00:00 2001 From: Phaeton <808865+Phaeton@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:17:56 -0400 Subject: [PATCH] Add '/400/' to '/full/' replacement for plane_images.csv (#376) * Add 400 to full replacement for plane_images.csv * black format --- .github/workflows/create_db_derivatives.yaml | 3 +++ scripts/update_image_links.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 scripts/update_image_links.py diff --git a/.github/workflows/create_db_derivatives.yaml b/.github/workflows/create_db_derivatives.yaml index 040c1f32..67d5a41e 100644 --- a/.github/workflows/create_db_derivatives.yaml +++ b/.github/workflows/create_db_derivatives.yaml @@ -31,6 +31,9 @@ jobs: - name: Update README.md to include changes run: python ./scripts/update_readme.py + - name: Update '/400/' paths to '/full/' + run: python ./scripts/update_image_links.py + - name: Commit derivative CSV files uses: stefanzweifel/git-auto-commit-action@v5 with: diff --git a/scripts/update_image_links.py b/scripts/update_image_links.py new file mode 100644 index 00000000..52d5d8af --- /dev/null +++ b/scripts/update_image_links.py @@ -0,0 +1,19 @@ +import logging + +logging.basicConfig( + format="%(asctime)s %(levelname)-8s [%(name)s] %(message)s", level=logging.INFO +) + +search_text = "https://cdn.jetphotos.com/400/" +replace_text = "https://cdn.jetphotos.com/full/" + +logging.info("Reading 'plane_images.csv'.") +with open(r"plane_images.csv", "r") as images: + data = images.read() + data = data.replace(search_text, replace_text) + +logging.info("Replace '/400/' paths with '/full/'.") +with open(r"plane_images.csv", "w") as images: + images.write(data) + +logging.info("Update image links complete.")