Parsing of a .include or .lib command. If the library exists and has not been called earlier, the path of the library will be stured in the list USERLIBS, and the library will be compiled (see: _compileUSERLibrary()). If the library does not exist the error count of the active circ
(line, name, cirType)
| 606 | _addModel(name, cirType, model) |
| 607 | |
| 608 | def _parseLibrary(line, name, cirType): |
| 609 | """ |
| 610 | Parsing of a .include or .lib command. If the library exists and has not |
| 611 | been called earlier, the path of the library will be stured in the list |
| 612 | USERLIBS, and the library will be compiled (see: _compileUSERLibrary()). |
| 613 | |
| 614 | If the library does not exist the error count of the active circuit will be |
| 615 | increased with one. |
| 616 | |
| 617 | The name of the active circuit object is the last name in the global |
| 618 | CIRCUITNAMES: CIRCUITNAMES[-1]. The circuit object itself is stored in the |
| 619 | dictionary CIRCUITS under this name: circuitDict[CIRCUITNAMES[-1]]. |
| 620 | |
| 621 | 1. Check of the file exists at the first of the following locations: |
| 622 | |
| 623 | 1. In the absolute path or path relative to the project directory |
| 624 | 2. In the circuit directory (ini.circuitPath) |
| 625 | 3. In the project library directory (ini.libraryPath) |
| 626 | |
| 627 | 2. Add the definitions of subcircuits, models and parameters to the globals |
| 628 | USERCIRCUITS, USERMODELS, and USERPARAMS, respectively |
| 629 | |
| 630 | Note: libraries are always global. |
| 631 | |
| 632 | :param line: list with tokens from a netlist line |
| 633 | :type line: list with tokens |
| 634 | |
| 635 | :param circuitDict: Dictionary to which the definition will be written, |
| 636 | defaults to CIRCUITS. |
| 637 | :type circuitDict: dictionary |
| 638 | |
| 639 | :return: Errors: number of errors found in this line. |
| 640 | |
| 641 | :rtype: Integer |
| 642 | """ |
| 643 | global _CIRCUITNAMES, _USERLIBS |
| 644 | for i in range(1, len(line)): |
| 645 | errors = 0 |
| 646 | if line[i].type == 'FNAME': |
| 647 | # 1. Check if the file exists: |
| 648 | # 1. Absolute path |
| 649 | # 2. In circuit directory (ini.circuitPath) |
| 650 | # 3. In project lib directory (ini.libraryPath) |
| 651 | # 2. Add definitions of circuits, models and parameters to the |
| 652 | # 3. USERCIRCUITS, USERMODELS and USERPARAMS (if not yet present) |
| 653 | # Libraries are always global! |
| 654 | fileName = line[i].value |
| 655 | if fileName == 'SLiCAP.lib': |
| 656 | _printError("Warning: a system library call in the netlist will be ignored.", line[i]) |
| 657 | return |
| 658 | else: |
| 659 | if os.path.exists(fileName): |
| 660 | pass |
| 661 | elif os.path.exists(ini.cir_path + fileName): |
| 662 | fileName = ini.cir_path + fileName |
| 663 | elif os.path.exists(ini.user_lib_path + fileName): |
| 664 | fileName = ini.user_lib_path + fileName |
| 665 | else: |
no test coverage detected