refdes_renum: warn of possible number clash with non-conforming values
[geda-gaf/whiteaudio.git] / examples / lightning_detector / bom
blobbc0f252410ef8844c8d5acb8a9e20fa559760a23
1 #!/usr/bin/python
2 import fileinput
3 import re
4 import commands
6 tempfile=open('workfile', 'w')
8 uref = "component"
9 value = "value"
10 text = "anything"
11 word_length = 0
14 for line in fileinput.input():
15 text = line
16 if re.search("uref=",text):
17 word_length = len(text) - 1 #remove newline
18 uref = text[5:word_length] #get component uref
20 if re.search("value=",text):
21 word_length = len(text) - 1 #remove newline
22 value = text[6:word_length] #get component value
23 #print uref,
24 #print "-------",
25 #print value
26 tempfile.write(uref)
27 tempfile.write(' ---------- ')
28 tempfile.write(value)
29 tempfile.write("\n")
31 tempfile.close()
33 print fileinput.filename()
35 x = open('workfile','r')
37 pp=fileinput.filename()
39 bom=open(pp +'.bom','w')
41 bom.write("Bill of Materials for "+ fileinput.filename() + '\n')
42 bom.write("\n")
43 bom.write("Component Value\n")
45 a = x.readlines()
46 a.sort()
47 for tuple in a:
48 bom.write(tuple)
49 bom.close()
50 x.close()
52 bom = open(pp + '.bom','r')
53 for line in bom.readlines():
54 print line,
56 commands.getoutput('rm workfile') #remove workfile