1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#The MIT License (MIT)
#PSpice to Oscad Schematic Converter
#This code is written by Suryavamshi Tenneti, FOSSEE, IIT Bombay
#The code is modified by Sumanto Kar and Gloria Nandihal, FOSSEE, IIT Bombay
import sys
import os
from attribute import *
from component_instance import *
from component import *
from design import *
from wire import *
from header import *
from misc import *
libDescr = 'EESchema-LIBRARY Version 4.7 Date: \n#encoding utf-8\n'
nameAppend = '_PSPICE'
REMOVEDCOMPONENTS = ['TITLEBLK', 'PARAM', 'readme', 'VIEWPOINT', 'LIB', 'copyright', 'WATCH1', 'VECTOR', 'NODESET1']
for fcounter in range(1, len(sys.argv[1:])+1):
input_file = open(sys.argv[fcounter], 'r+')
fbasename = os.path.basename(sys.argv[fcounter])
flname = fbasename[:fbasename.find('.')] + '.lib'
flib = open(flname, 'w+') #Write .lib header:
print('Library file name: ',flname)
flib.write(libDescr)
line = skipTo(input_file,'*symbol')
print('Parser',line)
'''
while(line != '' and '*symbol' not in line):
line = input_file.readline().strip()
print(line)
'''
while(line != '__ERROR__'):
#print(input_file.tell())
#print('Compo line',line)
d = line.find(' ')
cnametmp = line[d+1:]
#print('cnametmp',cnametmp)
d = cnametmp.find(' ')
if d == -1:
cname = cnametmp
else:
cname = cnametmp[0:d]
#print('cname->',cname)
fileTMP = open(sys.argv[fcounter])
c = Component(fileTMP, cname)
#print(c.ref)
fixComp(c)
#print('After fixComp',cname, 'ref=', c.ref)
write = True
for i in range(len(REMOVEDCOMPONENTS)): #Don't let these components be saved.
if cname == REMOVEDCOMPONENTS[i]:
write = False
break
#print('write->', write)
#print('line->', line)
if write:
c.type_ = c.type_ + nameAppend
c.print(flib)
'''line = input_file.readline().strip()
while(line != '' and '*symbol' not in line):
line = input_file.readline().strip()
print(line)
'''
line = skipTo(input_file, '*symbol')
flib.write('#\n#End Library\n')
flib.close()
|