Browse Source

Add tools

master
Dashie der otter 3 months ago
parent
commit
44f15f93b5
Signed by: Dashie <dashie@sigpipe.me> GPG Key ID: C2D57B325840B755
2 changed files with 34 additions and 0 deletions
  1. 9
    0
      README.md
  2. 25
    0
      extract_labels.py

+ 9
- 0
README.md View File

@@ -1,5 +1,14 @@
# Amiga 2000 KiCAD Schematics and PCB

# Various tools

## extract_labels.py
Use this script to quickly extract all Global Labels from wanted sheets.

```
./extract_labels.py agnus.sch amiga2000.sch chipram.sch coprocessor\ slot.sch denise.sch expansion\ logic.sch parallel.sch paula.sch pc\ slots.sch power.sch processor.sch serial.sch zorro.sch
```

# License

TBD

+ 25
- 0
extract_labels.py View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python3

import re, os, sys

#monster = re.compile("^Text GLabel (?P<posx>[\d]+) (?P<posy>[\d]+) (?P<orientation>[\d]+)(?:[\s]+)(?P<dimension>[\d]+)(?:[\s]+)(?P<shape>[\w]+) (?:.*)$\n^(?P<text>.+)$", re.MULTILINE)

monster = re.compile("^Text GLabel (?P<posx>[\d]+)(?:[\s]+)(?P<posy>[\d]+)(?:[\s]+)(?P<orientation>[\d]+)(?:.*)$\n^(?P<text>.+)$", re.MULTILINE)

labels = {}

if len(sys.argv) <= 1:
print(f"Usage: {sys.argv[0]} file1 file2 file3...")
exit(1)

for f in sys.argv[1:]:
with open(f, 'r') as ff:
labels[f] = {}
labels[f]['raw'] = monster.findall("".join(ff.readlines()))

for f in labels:
ls = labels[f]['raw']
lls = list(set([a[-1] for a in ls]))
labels[f]['labels'] = lls
print(f"{f}: {', '.join(lls)}")
print()

Loading…
Cancel
Save