From 31fc78d0e00f9c82f03c88367a7e23b2df918ca6 Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 5 Jan 2018 11:39:20 +0100 Subject: Add some documentation --- hw/chibi/chibi_2024/rotator.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 hw/chibi/chibi_2024/rotator.py (limited to 'hw/chibi/chibi_2024/rotator.py') diff --git a/hw/chibi/chibi_2024/rotator.py b/hw/chibi/chibi_2024/rotator.py new file mode 100755 index 0000000..cf45253 --- /dev/null +++ b/hw/chibi/chibi_2024/rotator.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import re + +with open('chibi_2024.kicad_pcb') as f: + lines = f.readlines() + +def mangled(lines): + for l in lines: + if 'fp_text' in l and not l.strip().endswith('hide'): + at_re = '\((at\s\S+\s\S+)(\s\S+)?\)' + match = re.search(at_re, l) + if not match: + raise Exception() + rot = int(match.group(2) or '0') + rot = (rot+180)%360 + yield re.sub(at_re, r'(\1 {})'.format(rot), l) + else: + yield l + +with open('out.kicad_pcb', 'w') as f: + f.write(''.join(mangled(lines))) -- cgit