blob: 62d0d0537f3dff4f96b5142492d284281816cb79 [file] [log] [blame]
Brian Silverman069eb252013-12-14 16:38:35 -08001#!/usr/bin/env ruby
2
3system 'rm temp.*'
4system 'gsch2pcb cape.gsch2pcb -o temp > /dev/null 2>&1'
5
6$elements = {}
7
8ElementRegex = /[ \t]*(Element[\[(].+) "(.*)" "(.*)" "(.*)" (.*)/
9
10File.open('temp.pcb') do |f|
11 f.readlines.each do |temp_element|
12 match = ElementRegex.match(temp_element)
13 if match
14 refdes = match[3]
15 value = match[4]
16 $elements[refdes] = value
17 end
18 end
19end
20
21File.open('cape.pcb') do |f|
22 $start_lines = f.readlines
23end
24
25File.open('cape.pcb', 'w') do |f|
26 $start_lines.each do |line|
27 match = ElementRegex.match(line)
28 if match
29 footprint = match[2]
30 refdes = match[3]
31 value = match[4]
32 f.puts "#{match[1]} \"#{footprint}\" \"#{refdes}\" \"#{$elements[refdes] || value}\" #{match[5]}"
33 else
34 f.puts line
35 end
36 end
37end