seveibar/am3352-ram-dogbone-and-single-layer-route-test

AM3352BZCZ100 processor connected to a W631GG6MB-12 DDR3 memory chip through a routed, length-matched 16-bit DDR interface with clock/data-strobe pairs and control/address signals.

Version
0.0.9
License
unset
Stars
0

scripts/compact-dist.py

"""Losslessly compact JSON and coalesce consecutive SVG paths for registry limits."""
import json,xml.etree.ElementTree as ET
from pathlib import Path
root=Path(__file__).resolve().parents[1]
for p in (root/'dist').rglob('*.json'):
 p.write_text(json.dumps(json.loads(p.read_text()),separators=(',',':'))+'\n')
p=root/'dist/index/pcb.svg';ET.register_namespace('', 'http://www.w3.org/2000/svg');tree=ET.parse(p)
for parent in list(tree.getroot().iter()):
 previous=None
 for child in list(parent):
  attrs={k:v for k,v in child.attrib.items() if k!='d'}
  if child.tag.endswith('}path') and previous is not None and attrs=={k:v for k,v in previous.attrib.items() if k!='d'}:
   previous.set('d',previous.get('d','')+' '+child.get('d',''));parent.remove(child)
  else:previous=child if child.tag.endswith('}path') else None
p.write_text(ET.tostring(tree.getroot(),encoding='unicode'))
for name in ['circuit.json','pcb.svg']:print(name,(root/'dist/index'/name).stat().st_size)