From c263636b86d204c9500ed2fe58e4f9db74c28bee Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Tue, 25 Jun 2019 12:55:20 +0530 Subject: Resolves #100 --- conf.py | 2 +- setup.py | 5 +++-- src/frontEnd/Application.py | 18 +++++++++++------- src/frontEnd/DockArea.py | 7 +++++-- src/frontEnd/ProjectExplorer.py | 2 +- src/kicadtoNgspice/KicadtoNgspice.py | 1 + src/kicadtoNgspice/Model.py | 4 ++-- src/kicadtoNgspice/Processing.py | 6 +++++- src/modelEditor/ModelEditor.py | 27 ++++++++++++--------------- src/ngspiceSimulation/pythonPlotting.py | 6 +++--- src/projManagement/Kicad.py | 2 -- src/projManagement/Validation.py | 18 ++++++------------ src/projManagement/Worker.py | 8 +++----- src/projManagement/newProject.py | 3 +-- src/projManagement/openProject.py | 2 +- 15 files changed, 55 insertions(+), 56 deletions(-) diff --git a/conf.py b/conf.py index b137e472..5aeb2574 100644 --- a/conf.py +++ b/conf.py @@ -17,7 +17,7 @@ import sys sys.path.insert(0, os.path.abspath('./src')) # added so that do not need to install them at runtime -autodoc_mock_imports = ["PyQt4","pathmagic","matplotlib","numpy"] +autodoc_mock_imports = ["PyQt4", "pathmagic", "matplotlib", "numpy"] # -- Project information ----------------------------------------------------- project = u'eSim' diff --git a/setup.py b/setup.py index 7a504733..497198b3 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ -from setuptools import setup, find_namespace_packages, Command # Always prefer setuptools over distutils +# Always prefer setuptools over distutils +from setuptools import setup, find_namespace_packages ''' Created for packaging and distributing of python projects @@ -16,4 +17,4 @@ setup( license='LICENSE', description='Useful circuit simulation library', long_description=open('README.md').read(), -) \ No newline at end of file +) diff --git a/src/frontEnd/Application.py b/src/frontEnd/Application.py index 97f895ad..c0dddf51 100755 --- a/src/frontEnd/Application.py +++ b/src/frontEnd/Application.py @@ -71,9 +71,11 @@ class Application(QtGui.QMainWindow): In this function we are setting icons, short-cuts,and defining functonality for: - - Top-tool-bar (New project, Open project, Close project, Help option ) - - Left-tool-bar (Open Schematic, Convert KiCad to NgSpice, Simuation, - Model Editor, Subcircuit, NGHDL, Modelica Converter, OM Optimisation ) + - Top-tool-bar (New project, Open project, Close project,\ + Help option ) + - Left-tool-bar (Open Schematic, Convert KiCad to NgSpice,\ + Simuation, Model Editor, Subcircuit, NGHDL, Modelica\ + Converter, OM Optimisation ) """ # Top Tool bar self.newproj = QtGui.QAction( @@ -199,11 +201,12 @@ class Application(QtGui.QMainWindow): exit message and buttons 'Yes', 'No'. 1. If 'Yes' is pressed: - - it checks that program(process) in procThread_list (list made in - Appconfig.py): + - it checks that program(process) in procThread_list\ + (list made in Appconfig.py): - if available it terminates that program - - if the program(process) is not available, it checks for it + - if the program(process) is not available,\ + it checks for it in process_obj (list made in Appconfig.py) if found it closes the program. @@ -341,7 +344,8 @@ class Application(QtGui.QMainWindow): # Fail Safe ===> count += 1 if count >= 100: - raise Exception("ngspice taking too long, check netlist file") + raise Exception( + "ngspice taking too long, check netlist file") # Calling Python Plotting try: diff --git a/src/frontEnd/DockArea.py b/src/frontEnd/DockArea.py index 99270366..0aa8ff17 100644 --- a/src/frontEnd/DockArea.py +++ b/src/frontEnd/DockArea.py @@ -20,7 +20,7 @@ class DockArea(QtGui.QMainWindow): """ This class contains function for designing UI of all the editors in dock area part: - + - Test Editor. - Model Editor. - Python Plotting. @@ -186,7 +186,10 @@ class DockArea(QtGui.QMainWindow): count = count + 1 def kicadToNgspiceEditor(self, clarg1, clarg2=None): - """This function is creating Editor UI for Kicad to Ngspice conversion.""" + """ + This function is creating Editor UI for- + Kicad to Ngspice conversion. + """ global count self.kicadToNgspiceWidget = QtGui.QWidget() self.kicadToNgspiceLayout = QtGui.QVBoxLayout() diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index e1e3ddad..638b3147 100644 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -56,7 +56,7 @@ class ProjectExplorer(QtGui.QWidget): pathlist = parents.split(os.sep) parentnode = QtGui.QTreeWidgetItem( self.treewidget, [pathlist[-1], parents] - ) + ) for files in children: QtGui.QTreeWidgetItem( parentnode, [files, os.path.join(parents, files)]) diff --git a/src/kicadtoNgspice/KicadtoNgspice.py b/src/kicadtoNgspice/KicadtoNgspice.py index f760bce2..ef9201cb 100644 --- a/src/kicadtoNgspice/KicadtoNgspice.py +++ b/src/kicadtoNgspice/KicadtoNgspice.py @@ -41,6 +41,7 @@ class MainWindow(QtGui.QWidget): - clarg1 is the path to the .cir file - clarg2 is either None or "sub" depending on the analysis type """ + def __init__(self, clarg1, clarg2=None): QtGui.QWidget.__init__(self) print("==================================") diff --git a/src/kicadtoNgspice/Model.py b/src/kicadtoNgspice/Model.py index 6ebfcb52..a182dd4e 100644 --- a/src/kicadtoNgspice/Model.py +++ b/src/kicadtoNgspice/Model.py @@ -115,8 +115,8 @@ class Model(QtGui.QWidget): self.obj_trac.model_entry_var [self.nextcount].setText( str(list(json_data - ["model"][mod]["values"] - [i].values())[0])) + ["model"][mod]["values"] + [i].values())[0])) ) i = i + 1 except BaseException: diff --git a/src/kicadtoNgspice/Processing.py b/src/kicadtoNgspice/Processing.py index ebbd3429..216383e6 100644 --- a/src/kicadtoNgspice/Processing.py +++ b/src/kicadtoNgspice/Processing.py @@ -16,6 +16,7 @@ class PrcocessNetlist: """ - Read the circuit file and return splitted lines """ + def readNetlist(self, filename): f = open(filename) data = f.read() @@ -31,6 +32,7 @@ class PrcocessNetlist: - Read Parameter information and store it into dictionary - kicadNetlis is the .cir file content """ + def readParamInfo(self, kicadNetlis): param = {} print("=========================KICADNETLIST========================") @@ -55,6 +57,7 @@ class PrcocessNetlist: - Preprocess netlist (replace parameters) - Separate infoline (first line) from the rest of netlist """ + def preprocessNetlist(self, kicadNetlis, param): netlist = [] for eachline in kicadNetlis: @@ -125,6 +128,7 @@ class PrcocessNetlist: - Then check for type whether ac, dc, sine, etc... - Handle starting with h and f as well """ + def insertSpecialSourceParam(self, schematicInfo, sourcelist): schematicInfo1 = [] print("=============================================================") @@ -462,7 +466,7 @@ class PrcocessNetlist: "a" + str(k) + " (" + words[1] + " " + words[2] + ") (interNode_" + str(interMediateNodeCount) + " " + words[3] + ") " - ) + ) modelLine += compName + "_primary" schematicInfo.append(modelLine) k = k + 1 diff --git a/src/modelEditor/ModelEditor.py b/src/modelEditor/ModelEditor.py index 9378ae25..634c1fe3 100644 --- a/src/modelEditor/ModelEditor.py +++ b/src/modelEditor/ModelEditor.py @@ -143,14 +143,14 @@ class ModelEditorclass(QtGui.QWidget): def diode_click(self): ''' - - Call function, openfiletype, which opens the table view for Diode specs + - Call function, openfiletype, which opens the table view\ + for Diode specs - Set states for other elements - Diode has no types, so hide that ''' self.openfiletype('Diode') self.types.setHidden(True) - def bjt_click(self): ''' - Set states for other elements @@ -170,7 +170,6 @@ class ModelEditorclass(QtGui.QWidget): # When element selected from combo box, call setfiletype self.types.activated[str].connect(self.setfiletype) - def mos_click(self): ''' - Set states for other elements @@ -193,7 +192,6 @@ class ModelEditorclass(QtGui.QWidget): self.openfiletype(filetype) self.types.activated[str].connect(self.setfiletype) - def jfet_click(self): ''' - Set states for other elements @@ -210,7 +208,6 @@ class ModelEditorclass(QtGui.QWidget): filetype = str(self.types.currentText()) self.openfiletype(filetype) self.types.activated[str].connect(self.setfiletype) - def igbt_click(self): ''' @@ -307,14 +304,14 @@ class ModelEditorclass(QtGui.QWidget): else: pass - def openedit(self): ''' - When `Edit` button clicked, this function called - Set states for other buttons accordingly - Open the file selector box with path as deviceModelLibrary and filetype set as .lib, save it in `self.editfile` - - Create table for the selected .lib file using `self.createtable(path)` + - Create table for the selected .lib file using\ + `self.createtable(path)` - Handle exception of no file selected ''' os.chdir(self.savepathtest) @@ -349,7 +346,8 @@ class ModelEditorclass(QtGui.QWidget): - Use ET (xml.etree.ElementTree) to parse the xml file - Extract data from the XML and store it in `modeldict` - Show the extracted data in QTableWidget - - Can edit QTable inplace, connect `edit_modeltable` function for editing + - Can edit QTable inplace, connect `edit_modeltable`\ + function for editing ''' self.savebtn.setDisabled(False) self.addbtn.setHidden(False) @@ -458,13 +456,14 @@ class ModelEditorclass(QtGui.QWidget): else: self.savethefile(self.editfile) - def createXML(self, model_name): ''' - Create .xml and .lib file if new model is being created - - Save it in the corresponding compoenent directory, example Diode, IGBT.. + - Save it in the corresponding compoenent directory,\ + example Diode, IGBT.. - For each component, separate folder is there - - Check the contents of .lib and .xml file to understand their structure + - Check the contents of .lib and .xml file to\ + understand their structure ''' root = ET.Element("library") ET.SubElement(root, "model_name").text = model_name @@ -604,10 +603,10 @@ class ModelEditorclass(QtGui.QWidget): txtfile.close() os.chdir(defaultcwd) - def validation(self, text): ''' - - This function checks if the file (xml type) with the name already exists + - This function checks if the file (xml type) with the name\ + already exists - Accordingly show error message ''' newfilename = text + '.xml' @@ -621,7 +620,6 @@ class ModelEditorclass(QtGui.QWidget): 'The file with name ' + text + ' already exists.') self.msg.setWindowTitle("Error Message") - def savethefile(self, editfile): ''' - This function save the editing in the model table @@ -667,7 +665,6 @@ class ModelEditorclass(QtGui.QWidget): self.modeltable.removeRow(index.row()) del self.modeldict[str(remove_item)] - def converttoxml(self): ''' - Called when upload button clicked diff --git a/src/ngspiceSimulation/pythonPlotting.py b/src/ngspiceSimulation/pythonPlotting.py index de6d958a..b9474403 100644 --- a/src/ngspiceSimulation/pythonPlotting.py +++ b/src/ngspiceSimulation/pythonPlotting.py @@ -626,7 +626,7 @@ class DataExtraction: p += 1 # 'p' gives no. of lines of data for each node/branch if "Index" in i: npv += 1 - # 'npv' gives the no of partitions for a single voltage node + # 'npv' gives the no of partitions for a single voltage node # print("npv:", npv) if "AC" in i: # DC for dc files and AC for ac ones break @@ -637,7 +637,7 @@ class DataExtraction: p += 1 if "Index" in i: npv += 1 - # 'npv' gives the no of partitions for a single voltage node + # 'npv' gives the no of partitions for a single voltage node # print("npv:", npv) if "Transient" in i: # DC for dc files and AC for ac ones break @@ -649,7 +649,7 @@ class DataExtraction: p += 1 if "Index" in i: npv += 1 - # 'npv' gives the no of partitions for a single voltage node + # 'npv' gives the no of partitions for a single voltage node # print("npv:", npv) if "DC" in i: # DC for dc files and AC for ac ones break diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index b75c0cf6..0b34015f 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -42,8 +42,6 @@ class Kicad: self.obj_appconfig = Appconfig() self.obj_dockarea = dockarea - - def openSchematic(self): """ This function create command to open Kicad schematic after diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index 79e458d8..65103282 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -22,8 +22,6 @@ import re import distutils.spawn - - class Validation: """ This is Validation class use for validating Project. @@ -41,12 +39,13 @@ class Validation: projName is same as the folder selected @params - :projDir => contains the path of the project folder selected to open + :projDir => contains the path of the project folder selected\ + to open @return True => If the folder contains the projName.proj file False => If the folder doesn't contain projName.proj file - """ + """ print("Function: Validating Open Project Information") projName = os.path.basename(str(projDir)) lookProj = os.path.join(str(projDir), projName + ".proj") @@ -56,8 +55,6 @@ class Validation: else: return False - - def validateNewproj(self, projDir): """ Validate new project created @@ -69,7 +66,7 @@ class Validation: :"CHECKEXIST" => If smae project name folder exists :"CHECKNAME" => If space is there in name :"VALID" => If valid project name given - """ + """ print("Function: Validating New Project Information") # Checking existence of project with same name @@ -82,8 +79,6 @@ class Validation: else: return "VALID" - - def validateKicad(self, projDir): """ Validate if projDir is set appropriately in the function calling file @@ -103,8 +98,6 @@ class Validation: else: return True - - def validateCir(self, projDir): """ Validate if cir file present in the directory with the appropriate .cir @@ -132,7 +125,8 @@ class Validation: @params :subDir => the path of the subcircuit directory - :giveNum => the number of port calculated and passed for validation + :giveNum => the number of port calculated and passed for\ + validation @return True diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py index 99d30ccc..9b9f57e4 100644 --- a/src/projManagement/Worker.py +++ b/src/projManagement/Worker.py @@ -19,6 +19,7 @@ from PyQt4 import QtCore import subprocess from configuration.Appconfig import Appconfig + class WorkerThread(QtCore.QThread): """ Initialise a QThread with the passed arguments @@ -39,8 +40,6 @@ class WorkerThread(QtCore.QThread): QtCore.QThread.__init__(self) self.args = args - - def __del__(self): """ __del__ is a called whenever garbage collection is initialised @@ -54,7 +53,6 @@ class WorkerThread(QtCore.QThread): """ self.wait() - def run(self): """ run is the function that is called, when we start the thread as @@ -77,8 +75,8 @@ class WorkerThread(QtCore.QThread): track processes called @params - :command => (self.args) takes space separated string of comamnds to - be executed in different child processes + :command => (self.args) takes space separated string of\ + comamnds to be executed in different child processes (see subproces.Popen()) """ diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index 92e90742..44a7a69a 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -23,7 +23,6 @@ import os import json - class NewProjectInfo(QtGui.QWidget): """ This class is called when User create new Project. @@ -39,7 +38,7 @@ class NewProjectInfo(QtGui.QWidget): This function create Project related directories and files. Before creating also validates using the `Validation` class - Validation codes + Validation codes - VALID - CHECKEXIST diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index 7c9e23d1..c1a56dbc 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -28,11 +28,11 @@ class OpenProjectInfo(QtGui.QWidget): """ This class is called when User click on Open Project Button """ + def __init__(self): super(OpenProjectInfo, self).__init__() self.obj_validation = Validation() - def body(self): """ Open a project directory using Qt GUI and validate -- cgit