#!/usr/bin/env python3 """Copy approved artwork to an explicit application checkout; --check detects drift.""" import argparse from pathlib import Path APPS = ["home", "docs", "sheets", "slides", "calendar", "calls", "memoria", "fichas"] # Apps with a native client, and where each keeps its icons. iOS applies its # own mask to a full-bleed square; the Mac takes the shaped icon on Apple's # grid, as PNG (Calls' AppKit resources) or as the Finder's .icns. NATIVE = { "calls": { "native/ios/Assets.xcassets/AppIcon.appiconset/AppIcon.png": "ios-1024.png", "native/apple/Sources/CallsMac/Resources/AppIcon.png": "macos-1024.png", "native/apple/Sources/CallsMac/Resources/MacIcon.png": "macos-1024.png", }, **{app: { "native/ios/Assets.xcassets/AppIcon.appiconset/AppIcon.png": "ios-1024.png", "native/macos/AppIcon.icns": "AppIcon.icns", } for app in ["docs", "sheets", "calendar", "memoria"]}, } parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("app", choices=APPS) parser.add_argument("checkout", type=Path) parser.add_argument("--check", action="store_true") args = parser.parse_args() source = Path(__file__).resolve().parent app = args.app destination = args.checkout / "internal" / app if not destination.is_dir(): parser.error("checkout does not contain internal/" + app) destination /= "brand" if app == "docs" else "static/brand" product = "oficina" if app == "home" else app files = { "icon.svg": source / "svg" / (product + ".svg"), "icon-32.png": source / "png" / (product + "-32.png"), "apple-touch-icon.png": source / "png" / (product + "-180.png"), "brand.css": source / "brand.css", "LICENSE.lucide": source / "LICENSE.lucide", } if app == "home": # The launcher shows every app, including those still to come. for name in ["docs", "sheets", "slides", "calendar", "calls", "memoria", "fichas", "mail", "files"]: files[name + ".svg"] = source / "svg" / (name + ".svg") copies = {destination / name: path for name, path in files.items()} for target, native in NATIVE.get(app, {}).items(): copies[args.checkout / target] = source / "native" / app / native for target, original in copies.items(): data = original.read_bytes() if args.check: if not target.is_file() or target.read_bytes() != data: raise SystemExit("Brand asset missing or stale: " + str(target)) else: target.parent.mkdir(parents=True, exist_ok=True) target.write_bytes(data) print(("Checked " if args.check else "Copied ") + str(len(copies)) + " assets for " + app)