Repository Public BSD-3-Clause
1#!/usr/bin/env python32# =============================================================================3# SP BOUCHER | SOFTWARE & RESEARCH4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# PROJECT METADATA8# -----------------------------------------------------------------------------9# Project : ORIX Maps10# File : scripts/collect-screenshots.py11# Description : Copies the documentation screenshots out of exported UI12# test attachments.13# Module : scripts14# Repository : https://git.spboucher.ai/orix-maps15# Created : 2026-11-2516# Last Modified : 2026-11-2517#18# =============================================================================19# AUTHOR & PROFESSIONAL AFFILIATION20# =============================================================================21#22# Author : Simon-Pierre Boucher23# Position : Professor of Finance24# Institution : Université du Québec en Outaouais (UQO)25# Department : Département des sciences administratives26# Organization : SP Boucher27#28# Website : https://spboucher.ai29# Git : https://git.spboucher.ai30#31# =============================================================================32# OFFICIAL CONTACT DIRECTORY33# =============================================================================34#35# General : info@spboucher.ai36# Professional : contact@spboucher.ai37# Direct : simon@spboucher.ai38# Research : research@spboucher.ai39# Development : dev@spboucher.ai40# Support : support@spboucher.ai41# Security/Admin : admin@spboucher.ai42# Notifications : notifications@spboucher.ai43#44# Preferred Contact: support@spboucher.ai45#46# =============================================================================47# COPYRIGHT & INTELLECTUAL PROPERTY48# =============================================================================49#50# Copyright (c) 202651# Simon-Pierre Boucher52#53# All rights reserved where applicable.54#55# This file is governed by the applicable project license,56# copyright notices, institutional agreements and relevant law.57#58# Unless expressly authorized by the applicable license or59# rights holder, copying, redistribution, sublicensing,60# publication and commercial exploitation are not permitted.61#62# Existing third-party rights and notices remain unaffected.63#64# =============================================================================65# CONFIDENTIALITY & SECURITY66# =============================================================================67#68# Classification : Public69# Distribution : Public repository; use is governed by the project license70# Security Contact : admin@spboucher.ai71#72# Access to this source does not independently grant permission73# to redistribute or disclose confidential materials.74#75# Do not embed credentials, private keys, access tokens,76# certificates or confidential personal information.77#78# =============================================================================79# LICENSE & MAINTENANCE80# =============================================================================81#82# License : Proprietary, all rights reserved (see license file)83# License File : LICENSE84# Maintainer : Simon-Pierre Boucher85# Technical Contact: dev@spboucher.ai86#87# =============================================================================88# END OF SP BOUCHER SOURCE HEADER89# =============================================================================9091"""Copies the documentation screenshots out of exported UI test attachments.9293usage: collect-screenshots.py <attachments dir exported by xcresulttool> <destination dir>9495UI tests attach captures named "docs-<name>" (see ORIXUITestCase.documentationScreenshot); each becomes96<destination>/<name>.png. Other attachments are left where they are. Standard library only.97"""98import json99import os100import re101import shutil102import sys103104source, destination = sys.argv[1], sys.argv[2]105with open(os.path.join(source, "manifest.json"), encoding="utf-8") as f:106 manifest = json.load(f)107os.makedirs(destination, exist_ok=True)108pattern = re.compile(r"^docs-(.+?)(?:_\d+_[0-9A-Fa-f-]{36})?\.png$")109copied = 0110for test in manifest:111 for attachment in test.get("attachments", []):112 m = pattern.match(attachment.get("suggestedHumanReadableName", ""))113 if not m:114 continue115 shutil.copyfile(os.path.join(source, attachment["exportedFileName"]), os.path.join(destination, m.group(1) + ".png"))116 copied += 1117print(f"collect-screenshots: {copied} capture(s) copied to {destination}")118