SPB Git

Repository Public

name-shots.py 1.2 KB 25 lines python

1#!/usr/bin/env python32# VQuant iOS3# File: Scripts/name-shots.py4# Description: Gives the attachments exported from a UI-test result bundle their readable names5#              (build/shots/<simulator>/named/<attachment name>.png), using the export's manifest.json.6#              usage: name-shots.py build/shots/VQuant_iPhone7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10import json, os, shutil, sys11d = sys.argv[1]12out = os.path.join(d, "named"); shutil.rmtree(out, ignore_errors=True); os.makedirs(out)13n = 014for test in json.load(open(os.path.join(d, "manifest.json"))):15    for a in test.get("attachments", []):16        name = a.get("suggestedHumanReadableName") or a.get("exportedFileName")17        src = os.path.join(d, a["exportedFileName"])18        if not os.path.exists(src) or not name.lower().endswith((".png", ".txt")): continue19        base = name.rsplit("_", 2)[0] if name.count("_") >= 2 else os.path.splitext(name)[0]20        ext = os.path.splitext(name)[1]21        target = os.path.join(out, base + ext)22        if os.path.exists(target): target = os.path.join(out, f"{base}-{n}{ext}")23        shutil.copy(src, target); n += 124print(n, "attachments named in", out)25
Files main
Menu

Theme