Turn audit.py into a run() function and drop audit_run.py, which only existed to import it quietly. Remove unused parameters, keys, helpers and imports from draw.py, manifest.py and stl_build.py, and the source file names in stl_build.FILES that pointed at nothing. Keep the brow strip's taper and knob positions in geom.py only. Correct comments and docstrings that disagreed with the code, and the README's claim about counts. The page changes only in markup: no stray spaces in class attributes, and three CSS declarations that did nothing are gone. Guide HTML, templates and print files are byte-identical apart from that. Credibility pass over a7c04e5..HEAD; the next one can scope from here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
56 lines
4.1 KiB
Python
56 lines
4.1 KiB
Python
"""Audit: walk the assembly in order and report, for every part, which face it is on, what it is glued to,
|
|
what it lies over, and what later covers it. Then check each step's written instructions against those facts."""
|
|
import re, manifest as M, content as C, geom as G
|
|
|
|
def run(verbose=True):
|
|
"""Return every problem found, including manifest.validate()'s. With verbose, print the walk-through too."""
|
|
say = print if verbose else (lambda *a: None)
|
|
base = G.base_glasses()['outline']
|
|
P = M.PLACEMENTS; order = list(M.STEPS); problems = []
|
|
for k in order:
|
|
st = M.STEPS[k]; ps = M.step_placements(k)
|
|
say(f"\n== {order.index(k)}. {st['title']} (drawing: {st['view']} view)")
|
|
for p in ps:
|
|
if p['shape'] is None: continue
|
|
same = [q for q in P if q is not p and q['shape'] is not None and q['face'] == p['face']]
|
|
fp = p['footprint']
|
|
under = [q['id'] for q in same if q['seq'] < p['seq'] and fp is not None and q['shape'].intersection(fp).area > 1]
|
|
over_earlier = [q['id'] for q in same if q['seq'] < p['seq'] and q['shape'].intersection(p['shape']).area > 15 and q['id'] not in under]
|
|
covered_later = [q['id'] for q in same if q['seq'] > p['seq'] and fp is not None and q['shape'].intersection(fp).area > 1]
|
|
on_base = fp.intersection(base).area / fp.area if fp is not None and fp.area else 0
|
|
say(f" {p['id']:16s} face={p['face']:6s} glue={p['glue']:7s} on-foam={on_base:4.0%} glued over: {under or '-'} lies across: {over_earlier or '-'} glue spot later covered by: {covered_later or '-'}")
|
|
# --- text checks
|
|
t = C.STEP[k]; text = re.sub(r'<[^>]+>', '', ' '.join(t['do']) + ' ' + t['check'])
|
|
faces = {p['face'] for p in ps if p['face'] in ('front', 'back') and p['part'] != 'STRAP'}
|
|
for f in faces:
|
|
if not re.search(rf'\b{f}\b', text): problems.append(f"step '{k}': parts go on the {f} but the text never says '{f}'")
|
|
wrong = {'front': 'back', 'back': 'front'}
|
|
for f in faces:
|
|
if len(faces) == 1 and re.search(rf'(to|on|onto) the (<b>)?{wrong[f]}(</b>)? of the band', ' '.join(t['do'])): problems.append(f"step '{k}': text says {wrong[f]} of the band, parts are on the {f}")
|
|
view = 'back' if st['view'] in ('back', 'both') else 'front'
|
|
if faces and view not in faces: problems.append(f"step '{k}': drawing is a {view} view but its parts are on the {faces}")
|
|
glues = {p['glue'] for p in ps} - {'none', 'wire'}
|
|
gl = t['glue'].lower()
|
|
if 'contact' in glues and 'cement' not in gl: problems.append(f"step '{k}': uses contact cement but the header says '{t['glue']}'")
|
|
if 'hot' in glues and 'hot' not in gl: problems.append(f"step '{k}': uses hot glue but the header says '{t['glue']}'")
|
|
# numbers in the text vs geometry
|
|
for p in ps:
|
|
if p['part'] in 'LMS' and p['x'] and k in ('back', 'centre', 'front'):
|
|
if not re.search(rf"\b{abs(round(p['x']))} mm", text): problems.append(f"step '{k}': {p['id']} sits {abs(round(p['x']))} mm from centre; text does not give that distance")
|
|
a = abs(round(p['ang']))
|
|
if a and not re.search(rf"\b{a}°", text): problems.append(f"step '{k}': {p['id']} leans {a} deg; text does not give that angle")
|
|
# chips = manifest counts
|
|
for part, n in C.step_counts(k).items():
|
|
if part in C.SHORT and C.qty(part, n) not in C.step_parts(k): problems.append(f"step '{k}': chip for {part} missing")
|
|
# twigs are glued to the front; no sentence anywhere in the guides may put them behind the leaves
|
|
for m in re.finditer(r"[^.'\n]{0,80}twig[^.'\n]{0,80}", open(C.__file__).read()):
|
|
if re.search(r'behind|backs? of', m.group(0)): problems.append('twigs go on the front, but the text says behind/back: ' + m.group(0).strip()[:140])
|
|
layout = M.validate(verbose=False)
|
|
say('\n== text vs layout problems:', len(problems))
|
|
for p in problems: say(' -', p)
|
|
say('manifest problems:', len(layout))
|
|
return problems + layout
|
|
|
|
if __name__ == '__main__':
|
|
import sys; sys.exit(1 if run() else 0)
|