(lines, cirTitle, language)
| 52 | return cirName |
| 53 | |
| 54 | def _parseKiCADnetlistlines(lines, cirTitle, language): |
| 55 | reserved = ["Description", "Footprint", "Datasheet"] |
| 56 | components = {} |
| 57 | nodes = {} |
| 58 | nodelist = [] |
| 59 | comps = False |
| 60 | title = False |
| 61 | subckt = False |
| 62 | subckt_lib = False |
| 63 | for line in lines: |
| 64 | # remove spaces in expression |
| 65 | try: |
| 66 | startExpr = line.index("{") |
| 67 | stopExpr = line.index("}", startExpr) |
| 68 | line = line[0:startExpr] + line[startExpr:stopExpr].replace(" ", "").replace("\t", "") + line[stopExpr:] |
| 69 | except ValueError: |
| 70 | pass |
| 71 | fields = line.split() |
| 72 | fields = [_removeParenthesis(field) for field in fields] |
| 73 | if fields[0] == "title": |
| 74 | if len(fields) > 1: |
| 75 | title = _checkTitle(" ".join(fields[1:])) |
| 76 | elif fields[0] == "comp": |
| 77 | newComp = _KiCADcomponent() |
| 78 | newComp.refDes = fields[fields.index('ref')+1][1:-1] |
| 79 | comps= True |
| 80 | elif fields[0] == "tstamps": |
| 81 | components[newComp.refDes] = newComp |
| 82 | comps = False |
| 83 | elif fields[0] == "value" and comps: |
| 84 | if language == "SLiCAP": |
| 85 | value = fields[fields.index("value")+1][1:-1] |
| 86 | elif language == "SPICE": |
| 87 | value = " ".join(fields[fields.index("value")+1:])[1:-1] |
| 88 | if value != '~': |
| 89 | newComp.params["value"] = value |
| 90 | elif fields[0] == "field" and comps: |
| 91 | try: |
| 92 | fieldName = fields[2][1:-1] |
| 93 | fieldValue = fields[3][1:-1] |
| 94 | if fieldName == "model": |
| 95 | newComp.model = fieldValue |
| 96 | elif fieldName[0:-1] == "ref": |
| 97 | newComp.refs.append(fieldValue) |
| 98 | elif fieldName == "Vsource": |
| 99 | newComp.refs.append(fieldValue) |
| 100 | elif fieldName == 'command': |
| 101 | newComp.command = ' '.join(fields[3:])[1:-1] |
| 102 | else: |
| 103 | newComp.params[fieldName] = fieldValue |
| 104 | except IndexError: |
| 105 | # Field has no value! |
| 106 | pass |
| 107 | elif fields[0] == 'net': |
| 108 | lastNode = fields[fields.index('name')+1][1:-1] |
| 109 | #lastNode = fields[4][1:-1] |
| 110 | nodes[lastNode] = lastNode |
| 111 | elif fields[0] == "node": |
no test coverage detected