simplipfy.Tools package
Submodules
simplipfy.Tools.forceDrawing module
- simplipfy.Tools.forceDrawing.forceDrawing(netlist: str, ls: dict, configOption: str = None) str
- Parameters:
netlist – str, netlist to be drawn
ls – LangSymbols dict
configOption – str, drawing config option to be used
- Returns:
str, SVG image data
Force drawing of a circuit with schemdraw, no checks applied simply drawing the components of the circuit If DrawWithSchemdraw raises a RuntimeError, the function will return an SVG image with the errors and warnings
- simplipfy.Tools.forceDrawing.generateSVGWithErrorsAndWarnings(netlist)
simplipfy.Tools.generateGraphs module
- simplipfy.Tools.generateGraphs.generate_for_folder_structure(folderPath: str, saveFolder='CircuitGraphs')
- Parameters:
folderPath – path to the folder to generate for, only generates for files with extension .txt, .sch
saveFolder – name of the folder where the graph.png files are saved. This is created at the same level as the
source folder lives. Therefore, source folder and save folder cant have the same name. :return: None :Note: The save folder is removed and recreated.
- simplipfy.Tools.generateGraphs.generate_graph_from_circuit(cct: Circuit, fName: str, path='')
simplipfy.Tools.generateSVGFiles module
- class simplipfy.Tools.generateSVGFiles.SVGFileGenerator(folderPath: str)
Bases:
objectClass to generate the svg files for the Circuits folder. This class validates the folder structure to assert it works with simplify frontend. If you only want to generate a svg file use simpliPFyAPI.forceDrawing instead.
- allowedFolders = {'capacitor', 'inductor', 'kirchhoff', 'mixed', 'quickstart', 'resistor', 'symbolic', 'wheatstone'}
- generateAllFiles(raiseEx: bool = True) int
- Parameters:
raiseEx – if True, raise an RuntimeError if the svg file generation fails.
If False, return the number of failed files. :returns: None :raises: RuntimeError if raiseEx is True and the svg file generation fails for one file.
Remove all svg files in the folder specified by self.folderPath and generate new svg files for each circuit file (.txt or .sch) in the folder.
- generateSVGFile(filePath: str) int
- Parameters:
filePath – path to the circuit file with name and extension
- Returns:
int error code
0 if the svg file was generated successfully,
1 if the svg file was not found,
2 if the circuit file is not valid,
3 if generating the file throws an error
Generates the svg file for the given circuit file.
- getFilteredFiles(exts: list[str]) list[str]
exts: list of file extensions to filter for e.g. [‘.txt’, ‘.sch’] :returns: list of files with the given extensions
- removeSVGFiles()
Removes all svg files in the folder specified by self.folderPath
simplipfy.Tools.printColored module
- class simplipfy.Tools.printColored.CPrintColors(*values)
Bases:
EnumANSI escape codes for colored text in the terminal.
- BLUE = '\x1b[94m'
- CYAN = '\x1b[96m'
- FAIL = '\x1b[91m'
- GREEN = '\x1b[92m'
- HEADER = '\x1b[95m'
- OKBLUE = '\x1b[94m'
- OKCYAN = '\x1b[96m'
- OKGREEN = '\x1b[92m'
- PURPLE = '\x1b[95m'
- RED = '\x1b[91m'
- WARNING = '\x1b[93m'
- YELLOW = '\x1b[93m'
- simplipfy.Tools.printColored.cPrint(text: str, color: CPrintColors = CPrintColors.RED, bold=False, underline=False)
param text: str to print param color: BColors enum value to set the color of the text
Print colored text to the console, with a default color of red.
simplipfy.Tools.validateCircuitFile module
- class simplipfy.Tools.validateCircuitFile.ValidateCircuitFile(fileName: str = None, filePath: str = '', fileStr: str = None, valueType: ValueType = ValueType.any)
Bases:
objectClass to validate a circuit file. Use: init the class with the file name and path or the file content as string
1: isValid() -> bool, valid if True in self.errMsg and self.warnMsg are the error and warning messages a call to isValid() or validate() will reset the error and warning messages 2: validate() -> tuple[bool, str, str], bool True if valid, str error str error messages, str warning messages
- property errMsgs: str
a string with all error messages found while running self.validate() or self.isValid()
- Type:
returns
- isValid(warnings=True) bool
- Parameters:
warnings – bool, if True print warnings
- Retuns:
bool, True if the circuit file is valid, False otherwise
Check if the circuit file is valid and return a boolean value.
- resetErrAndWarnMsg()
- validate(warnings=True) tuple[bool, str, str]
- Parameters:
warnings – bool, True if warnings should be returned, if false [bool, str, “”]
- Returns:
[bool, str, str]
Ture if the circuit file is valid, False otherwise
str error messages
str warning messages
Validate the circuit file and return error and warn messages.
- validateSemantic()
- validateSyntax()
- property warnMsgs: str
returns a string with all warning messages found while running self.validate() or self.isValid()
simplipfy.Tools.zipFolder module
- simplipfy.Tools.zipFolder.zip_folder(folderPath: str, zipPath: str = None, zipFolderName: str = None, deleteSource: bool = True)
- Parameters:
folderPath – The path to the folder to zip.
zipPath – The path where the zip file will be created. If None, the zip file will be created in the same directory as the folder.
zipFolderName – The name of the zipped folder. If None, the basename of folderPath is used.
deleteSource – If True, the source folder will be deleted after zipping. Default is True.
Compresses the contents of a folder into a zip file.
Module contents
Python files that solve specific tasks not related to a specific package or module.