#. Replaces text labels on a KiCAD schematic with : #. Creates drawing-size ``svg`` and ``pdf`` images of the annotated schematic #. Saves the annotated schematic :param sch: File of the KiCAD schematic with annotation text labels;
(sch, opinfo)
| 238 | return netlist, subckt |
| 239 | |
| 240 | def backAnnotateSchematic(sch, opinfo): |
| 241 | """ |
| 242 | #. Replaces text labels <label> on a KiCAD schematic with <label>:<opinfo[label]> |
| 243 | #. Creates drawing-size ``svg`` and ``pdf`` images of the annotated schematic |
| 244 | #. Saves the annotated schematic |
| 245 | |
| 246 | :param sch: File of the KiCAD schematic with annotation text labels; |
| 247 | location relative to project directory |
| 248 | :type sch: str |
| 249 | |
| 250 | :param opinfo: Dictionary with key-value pairs: |
| 251 | |
| 252 | - key: label text |
| 253 | - value: text to be appended to the label |
| 254 | :return: None |
| 255 | :rtype: NoneType |
| 256 | """ |
| 257 | f = open(sch, "r") |
| 258 | schematic = f.read() |
| 259 | f.close() |
| 260 | replacements = {} |
| 261 | for name in opinfo.keys(): |
| 262 | m = re.search(rf'(\(text "{name})(\:\s?[+-]?\d+\.?\d*)?([eE][+-]?\d+)?"', schematic) |
| 263 | if m != None: |
| 264 | replacements[m.group(0)] = m.group(1) + ': {:8.2e}"' .format(opinfo[name]) |
| 265 | for replacement in replacements.keys(): |
| 266 | schematic = schematic.replace(replacement, replacements[replacement]) |
| 267 | f = open(sch, "w") |
| 268 | f.write(schematic) |
| 269 | f.close() |
| 270 | KiCADsch2svg(sch) |
| 271 | |
| 272 | if __name__=='__main__': |
| 273 | from SLiCAP import initProject |
nothing calls this directly
no test coverage detected