Files
Sylpheed/tools/re-capture/effect_homes.py
sim e909c7c133 chore: retire the last dead paths and names from the consolidation
Nothing here changes what a tool computes; it changes where tools look.

- tools/re-capture: 33 censuses globbed /work/sylph_extract, a path that has
  existed nowhere since /work became a clone, so they matched nothing and
  printed empty results. They now resolve the disc through a new disc.py
  from $SYLPHEED_DISC and exit loudly without it (the #44 fix, generalised).
  Nine scripts that imported siblings from the retired Reborn checkout or an
  old session scratchpad now import from their own directory. unitgroup.py
  only needs the variable when --pak is not given.
- sylpheed-xex: the loader only ever uses the XEX2 retail key. The dead
  devkit key and a doc comment claiming a devkit fallback that does not
  exist are gone; Project Sylpheed is a retail XEX2, so no XEX1 key either.
- sylpheed-viewer: real_font_rasterizes looked for /tmp/sylph_extract and so
  always skipped. It reads $SYLPHEED_DISC now, and passes against the disc.
- Comments and docs that named xenia-rs, the Reborn repository or /work/*.pe
  as places to look now name sylpheed.db, Canary's ppc_context.h and the
  flat .pe; docs/re/README.md no longer says the native Canary build does not
  run.

Historical records keep their original paths: findings that were measured
against /work/xenia-rs/sylpheed.db still say so.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 22:30:28 +02:00

81 lines
3.0 KiB
Python

#!/usr/bin/env python3
"""Which .xpr package holds each effect the datasheets bind.
Effect names are matched EXACTLY, not as substrings: Base.xpr contains
eff_f0002_barnhaze, so a substring test for "eff_f0002" reports a false hit for
a resource that is not there. Names are pulled as maximal [A-Za-z0-9_] runs
containing "eff_", which yields whole resource names -- 268 of ptc_pack's 727
carry an EF_IDX_ prefix, so a pattern anchored at "eff_" would truncate them and
silently merge distinct names. A bound name is looked up bare AND under that
prefix.
Regenerates docs/re/data/effect-homes.txt.
"""
import glob, os, re, subprocess, sys, collections
from disc import disc_root
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from unit_substructures import pak_entries
import unitgroup as U
XPR = disc_root() + '/hidden/resource3d'
FX = re.compile(r'(FxModel|EffectName|Effect_|ShellModel|CoverModel)')
def width(n):
m = re.match(r'eff_[a-z](\d+)', n)
return len(m.group(1)) if m else 0
def main():
if not os.path.isdir(XPR):
print('disc not mounted; nothing to do'); return
home = collections.defaultdict(set)
for path in sorted(glob.glob(os.path.join(XPR, '*.xpr'))):
out = subprocess.run(['grep', '-o', '-a', '[A-Za-z0-9_]*eff_[A-Za-z0-9_]*', path],
capture_output=True, text=True, errors='replace').stdout
for name in set(out.split()):
home[name].add(os.path.basename(path))
bound = set()
for pk in sorted(glob.glob(disc_root() + '/**/*.pak', recursive=True)):
for _h, b in pak_entries(pk):
if b[:4] != b'IDXD':
continue
try:
recs = U.parse(b)
except Exception:
continue
for r in recs:
for _t, f, v in r['fields']:
if f and FX.search(f) and isinstance(v, str) and v.startswith('eff_'):
bound.add(v)
# a name may be stored bare or under the EF_IDX_ index prefix
def where(n):
return home.get(n, set()) | home.get('EF_IDX_' + n, set())
res = sorted(n for n in bound if where(n))
un = sorted(n for n in bound if not where(n))
print('effect names bound by a datasheet field : %d' % len(bound))
print('resolved to an .xpr package (exact name): %d' % len(res))
print('unlocated : %d' % len(un))
print()
per = collections.Counter()
for n in res:
for f in where(n):
per[f] += 1
print('resolved, by package:')
for f, k in sorted(per.items(), key=lambda kv: (-kv[1], kv[0])):
print(' %-26s %d' % (f, k))
print()
print('by digit-width:')
for k in (3, 4, 0):
s = [n for n in bound if width(n) == k]
if s:
print(' %d-digit: %d resolved of %d' % (k, len([n for n in s if where(n)]), len(s)))
print()
print('the %d unlocated, in full:' % len(un))
for n in un:
print(' %s' % n)
if __name__ == '__main__':
main()