- 정리는 코치 세션이 저장소 밖 도구로 수행, 하이쿠 세션이 커밋. - 옛 81커밋은 로컬에만 보존. 기록은 evidence/gitlog_v1.txt. - F13 기준 변경: .gitignore 에 private/*.dwg·private/full.dxf 제외 (SPEC 34장 끝 문장). - check.sh 결과: 결과: PASS 151 / FAIL 0 / SKIP 3 (검사 범위 F01~F46) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
# prep_drawing.py — 도면 SVG 를 화면에서 선명하게 만든다 (표준 라이브러리만 사용)
|
|
# 사용: python3 tools/prep_drawing.py <원본.svg> private/drawing.svg
|
|
# 원본은 고치지 않는다. 0 이 아닌 stroke-width 를 1 로 바꾸고,
|
|
# 루트 <svg> 바로 안에 <style> 을 넣어 모든 선이 화면 1px 로 그려지게 한다.
|
|
import re
|
|
import sys
|
|
|
|
|
|
def prep(text):
|
|
# 선 굵기 속성: stroke-width="0.75" → "1" (0 은 그대로 둔다: 선 없음)
|
|
def fix_attr(m):
|
|
value = m.group(1)
|
|
try:
|
|
if float(value) == 0:
|
|
return m.group(0)
|
|
except ValueError:
|
|
return m.group(0)
|
|
return 'stroke-width="1"'
|
|
|
|
text = re.sub(r'stroke-width="([^"]*)"', fix_attr, text)
|
|
|
|
# style 속성 안의 stroke-width:0.75 도 같은 규칙
|
|
def fix_style(m):
|
|
try:
|
|
if float(m.group(1)) == 0:
|
|
return m.group(0)
|
|
except ValueError:
|
|
return m.group(0)
|
|
return 'stroke-width:1'
|
|
|
|
text = re.sub(r'stroke-width:\s*([0-9.]+)', fix_style, text)
|
|
|
|
# 루트 <svg ...> 바로 뒤에 모든 요소의 선을 화면 기준으로 고정
|
|
style = '<style>* { vector-effect: non-scaling-stroke; }</style>'
|
|
text, n = re.subn(r'(<svg\b[^>]*>)', lambda m: m.group(1) + style, text, count=1)
|
|
if n != 1:
|
|
raise SystemExit('루트 <svg> 태그를 찾지 못했다')
|
|
return text
|
|
|
|
|
|
def main(argv):
|
|
if len(argv) != 3:
|
|
print('사용법: python3 tools/prep_drawing.py <원본.svg> <출력.svg>')
|
|
return 2
|
|
src, dst = argv[1], argv[2]
|
|
with open(src, encoding='utf-8') as f:
|
|
text = f.read()
|
|
with open(dst, 'w', encoding='utf-8') as f:
|
|
f.write(prep(text))
|
|
print(f'완료: {dst}')
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(sys.argv))
|