Files
novalon-website/deliverables/logo-redesign-2026-10-13/dump-jianbiao.py
T
zhangxiang a57826f710 docs(brand): 品牌全案手册与落库证据入库(判据、门禁、负例都在场)
BRAND-MANUAL.md 收敛识别方案裁定与实测判据;TOKEN-MIGRATION.md 记 P1/P3/P4 迁移面与孪生缺陷;
TEST-PATCH.md 记 P7 的 1→0 实测。随包入库的是结论赖以成立的仪器与证据:check-assets、check-manual、
verify-assets-cross、check-wordmark-copies、check-docsync、check-probes(四段闸,每段带能失败的负例)、
check-baseline-shift.cjs(平移感知基线判据,四合成样本两绿两红自测通过;它取代被证伪的
「diff 包围盒不许越页眉带」)与 measured/baseline-shift-p1.json(第一批 104 张逐张分类,带 _src 出处戳)。

大体积工作件不入库:样机 HTML 与栅格截图 100+MB、字体母版 45MB 留在盘上,入库 690 个文本/矢量件。
2026-10-16 19:23:28 +08:00

80 lines
3.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""把第四十五刀定下来的两枚东西落成可用文件,并【回读校验】——
不看生成器返回值,看磁盘上真正有什么。"""
import os
import re
import importlib.util
HERE = os.path.dirname(os.path.abspath(__file__))
sp = importlib.util.spec_from_file_location("jb", os.path.join(HERE, "jianbiao.py"))
jb = importlib.util.module_from_spec(sp)
sp.loader.exec_module(jb)
OUT = os.path.join(HERE, "assets-jianbiao")
os.makedirs(OUT, exist_ok=True)
def seal_file(face, dg, px=None):
s = jb.seal_wen(px if px else 100, face=face, dg=dg)
if px is None:
s = re.sub(r' width="\d+(\.\d+)?" height="\d+(\.\d+)?"', '', s, count=1)
else:
s = re.sub(r' width="\d+(\.\d+)?" height="\d+(\.\d+)?"',
' width="%d" height="%d"' % (px, px), s, count=1)
return s
def avatar_file(kind):
s = jb.avatar(512, kind)
return re.sub(r' width="\d+(\.\d+)?" height="\d+(\.\d+)?"', '', s, count=1)
FILES = {
"jianbiao-seal.svg": (seal_file(0.78, 0.0),
"简标·主刻版(可缩放):朱砂方印 白文睿,字面 0.78"),
"jianbiao-seal-16.svg": (seal_file(0.92, 0.5, 16),
"简标·16px 专用刻版:字面 0.92 + 减地 0.5px。"
"减地按【设备像素】定义,所以这一版绑死 16px,放大就废"),
"avatar-ring2.svg": (avatar_file("ring2"),
"头像·红盘 + 粗白环 4.5% + 字面 0.68(可缩放)"),
"avatar-full.svg": (avatar_file("full"),
"头像·红盘 + 字面 0.80,保留率最优(可缩放)"),
}
if __name__ == "__main__":
bad = 0
for name, (body, note) in FILES.items():
path = os.path.join(OUT, name)
with open(path, "w", encoding="utf-8") as f:
f.write('<!-- ' + note + ' -->\n' + body)
back = open(path, encoding="utf-8").read()
# 回读校验:能解析、有且仅有一个 path、睿的路径没被截断、
# 【根标签】有没有固定宽高 —— 上一版这里用 \bwidth="\d 全文扫,
# 结果被 stroke-width="4.5" 和印面 <rect width="100"> 两处误命中,
# 把两个本来正确的文件判成 FAIL。探针误报比漏报更难发现,因为它让你去改对的东西。
# 根标签 = 【<svg 之后】的第一个标签。上一版直接 back.split(">")[0],
# 结果切到的是开头那行注释(它以 --> 收尾),root 永远没有 width,
# 三个 OK 全是空判 —— 判据不成立时"通过"比"失败"更危险。
svg_part = back[back.index("<svg"):]
root = svg_part.split(">", 1)[0]
import xml.etree.ElementTree as ET
try:
ET.fromstring(svg_part)
parses = True
except Exception as e: # noqa: BLE001
parses = False
print(" parse error:", e)
npath = back.count("<path ")
has_d = 'd="M' in back or 'd="m' in back
fixed = bool(re.search(r'\swidth="\d', root))
expect_fixed = name.endswith("-16.svg")
ok = (back.startswith("<!--") and root.startswith("<svg") and parses
and npath == 1 and has_d and len(back) > 2000 and fixed == expect_fixed)
print("%-24s %7d B xml=%s path=%d 根标签=%s 固定宽高=%s(期望 %s) %s"
% (name, len(back.encode()), parses, npath,
"svg" if root.startswith("<svg") else root[:12], fixed, expect_fixed,
"OK" if ok else "FAIL"))
bad += 0 if ok else 1
print("校验失败数:", bad)