scripts.shopify.remove_extra_images =================================== .. py:module:: scripts.shopify.remove_extra_images .. autoapi-nested-parse:: Deletes every image but the first from every Shopify product. ``uv run python -m scripts.shopify.remove_extra_images`` (or ``make remove-extra-images``). A product shows exactly one image: the Model's first "Photo neuve". ``create_product_shopify`` and ``update_product`` used to also upload the other "Photo neuve" attachments and a unit's "Photos marketplace"; this removes those from products already online, in one pass. The image kept is the one at position 1 -- the first one uploaded, i.e. the first "Photo neuve". On each product changed, the ``custom.images_airtable_ids`` metafield ``update_product`` diffs against is trimmed to its first line too, so the next ``update_product`` run sees the images as up to date instead of re-uploading the same picture. Products with at most one image are skipped, so a rerun is a no-op. Prints a plan and asks for a typed confirmation before deleting anything, unless ``--yes`` is given; ``--dry-run`` only prints the plan. Attributes ---------- .. autoapisummary:: scripts.shopify.remove_extra_images.NAMESPACE scripts.shopify.remove_extra_images.SOURCE_KEY scripts.shopify.remove_extra_images.REQUEST_DELAY_SECONDS scripts.shopify.remove_extra_images.MAX_RETRIES Classes ------- .. autoapisummary:: scripts.shopify.remove_extra_images.Product scripts.shopify.remove_extra_images.Rest Functions --------- .. autoapisummary:: scripts.shopify.remove_extra_images.list_products scripts.shopify.remove_extra_images.trim_source_metafield scripts.shopify.remove_extra_images.clean scripts.shopify.remove_extra_images.parse_args scripts.shopify.remove_extra_images.main Module Contents --------------- .. py:data:: NAMESPACE :value: 'custom' .. py:data:: SOURCE_KEY :value: 'images_airtable_ids' .. py:data:: REQUEST_DELAY_SECONDS :value: 0.5 .. py:data:: MAX_RETRIES :value: 5 .. py:class:: Product .. py:attribute:: id :type: int .. py:attribute:: title :type: str .. py:attribute:: image_ids :type: list[int] .. py:class:: Rest(domain: str, token: str, api_version: str) .. py:attribute:: base_url .. py:attribute:: token .. py:function:: list_products(rest: Rest) -> list[Product] .. py:function:: trim_source_metafield(rest: Rest, product: Product) -> str | None Keeps only the first attachment id; None on success, else the error. .. py:function:: clean(rest: Rest, product: Product) -> list[str] Deletes every image but the first; returns the errors. .. py:function:: parse_args(argv: collections.abc.Sequence[str] | None = None) -> argparse.Namespace .. py:function:: main(argv: collections.abc.Sequence[str] | None = None) -> int