From 30c607ef581345958f0f9bdb5dd5603a1dd774c8 Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Sun, 31 Mar 2019 04:28:27 +0530 Subject: port to python3 --- src/projManagement/Kicad.py | 8 +++---- src/projManagement/Validation.py | 12 +++++----- src/projManagement/Worker.py | 26 ++++++++++------------ src/projManagement/Worker.py.bak | 46 +++++++++++++++++++++++++++++++++++++++ src/projManagement/newProject.py | 2 +- src/projManagement/openProject.py | 4 ++-- 6 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 src/projManagement/Worker.py.bak (limited to 'src/projManagement') diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index ec3c69da..d4ee9b42 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -17,9 +17,9 @@ #=============================================================================== import os -import Validation +from . import Validation from configuration.Appconfig import Appconfig -import Worker +from . import Worker from PyQt4 import QtGui class Kicad: @@ -35,7 +35,7 @@ class Kicad: """ This function create command to open Kicad schematic """ - print "Function : Open Kicad Schematic" + print("Function : Open Kicad Schematic") self.projDir = self.obj_appconfig.current_project["ProjectName"] try: self.obj_appconfig.print_info('Kicad Schematic is called for project ' + self.projDir) @@ -123,7 +123,7 @@ class Kicad: """ This function create command to call kicad to Ngspice converter. """ - print "Function: Open Kicad to Ngspice Converter" + print("Function: Open Kicad to Ngspice Converter") self.projDir = self.obj_appconfig.current_project["ProjectName"] try: diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index a582cab5..b401e5e1 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -34,7 +34,7 @@ class Validation: """ This function validate Open Project Information. """ - print "Function: Validating Open Project Information" + print("Function: Validating Open Project Information") projName = os.path.basename(str(projDir)) lookProj = os.path.join(str(projDir),projName+".proj") #Check existence of project @@ -49,7 +49,7 @@ class Validation: """ This Project Validate New Project Information """ - print "Function: Validating New Project Information" + print("Function: Validating New Project Information") #Checking existence of project with same name if os.path.exists(projDir): @@ -65,7 +65,7 @@ class Validation: """ This function validate if Kicad components are present """ - print "FUnction : Validating for Kicad components" + print("FUnction : Validating for Kicad components") if projDir == None: return False else: @@ -104,9 +104,9 @@ class Validation: #The number of ports is specified in this line #eg. '.subckt ua741 6 7 3' has 3 ports (6, 7 and 3). numPorts = len(words) - 2 - print "Looksub : ",lookSub - print "Given Number of ports : ",givenNum - print "Actual Number of ports :",numPorts + print("Looksub : ",lookSub) + print("Given Number of ports : ",givenNum) + print("Actual Number of ports :",numPorts) if numPorts != givenNum: return "PORT" else: diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py index 6befca65..f0fe7234 100644 --- a/src/projManagement/Worker.py +++ b/src/projManagement/Worker.py @@ -1,18 +1,18 @@ #=============================================================================== # # FILE: WorkerThread.py -# -# USAGE: --- -# +# +# USAGE: --- +# # DESCRIPTION: This class open all third party application using QT Thread -# +# # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. -# CREATED: Tuesday 24 Feb 2015 +# CREATED: Tuesday 24 Feb 2015 # REVISION: --- #=============================================================================== from PyQt4 import QtCore @@ -26,21 +26,17 @@ class WorkerThread(QtCore.QThread): def __init__(self,args): QtCore.QThread.__init__(self) self.args = args - - + + def __del__(self): self.wait() - + def run(self): - print "Worker Thread Calling Command :",self.args + print("Worker Thread Calling Command :",self.args) self.call_system(self.args) - + def call_system(self,command): procThread = Appconfig() proc = subprocess.Popen(command.split()) procThread.procThread_list.append(proc) - procThread.proc_dict[procThread.current_project['ProjectName']].append(proc.pid) - - - - + procThread.proc_dict[procThread.current_project['ProjectName']].append(proc.pid) diff --git a/src/projManagement/Worker.py.bak b/src/projManagement/Worker.py.bak new file mode 100644 index 00000000..575ea12c --- /dev/null +++ b/src/projManagement/Worker.py.bak @@ -0,0 +1,46 @@ +#=============================================================================== +# +# FILE: WorkerThread.py +# +# USAGE: --- +# +# DESCRIPTION: This class open all third party application using QT Thread +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Fahim Khan, fahim.elex@gmail.com +# ORGANIZATION: eSim team at FOSSEE, IIT Bombay. +# CREATED: Tuesday 24 Feb 2015 +# REVISION: --- +#=============================================================================== +from PyQt4 import QtCore +import subprocess +from configuration.Appconfig import Appconfig + +class WorkerThread(QtCore.QThread): + """ + This is Thread class use to run the command + """ + def __init__(self,args): + QtCore.QThread.__init__(self) + self.args = args + + + def __del__(self): + self.wait() + + def run(self): + print("Worker Thread Calling Command :",self.args) + self.call_system(self.args) + + def call_system(self,command): + procThread = Appconfig() + proc = subprocess.Popen(command.split()) + procThread.procThread_list.append(proc) + procThread.proc_dict[procThread.current_project['ProjectName']].append(proc.pid) + + + + diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index 5b4af49a..e8c81d6f 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -17,7 +17,7 @@ # REVISION: --- #=============================================================================== from PyQt4 import QtGui -from Validation import Validation +from .Validation import Validation from configuration.Appconfig import Appconfig import os import json diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index d980d914..c71d2181 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -18,7 +18,7 @@ #=============================================================================== from PyQt4 import QtGui -from Validation import Validation +from .Validation import Validation from configuration.Appconfig import Appconfig import os import json @@ -40,7 +40,7 @@ class OpenProjectInfo(QtGui.QWidget): if self.obj_validation.validateOpenproj(self.projDir) == True: self.obj_Appconfig.current_project['ProjectName'] = str(self.projDir) if os.path.isdir(self.projDir): - print "true" + print("true") for dirs, subdirs, filelist in os.walk(self.obj_Appconfig.current_project["ProjectName"]): directory = dirs -- cgit From 28d8fd378bf717e8daba8a564708856769f24b98 Mon Sep 17 00:00:00 2001 From: maddy-2 Date: Mon, 27 May 2019 12:32:49 +0530 Subject: initialise pep8 compliance, using autopep8 --- src/projManagement/Kicad.py | 125 ++++++++++++++++++++------------------ src/projManagement/Validation.py | 98 +++++++++++++++--------------- src/projManagement/Worker.py | 16 ++--- src/projManagement/newProject.py | 99 ++++++++++++++++-------------- src/projManagement/openProject.py | 56 +++++++++-------- 5 files changed, 203 insertions(+), 191 deletions(-) (limited to 'src/projManagement') diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index d4ee9b42..2fc17615 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -1,20 +1,20 @@ -#=============================================================================== +#========================================================================= # # FILE: openKicad.py -# -# USAGE: --- -# +# +# USAGE: --- +# # DESCRIPTION: It call kicad schematic -# +# # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. -# CREATED: Tuesday 17 Feb 2015 +# CREATED: Tuesday 17 Feb 2015 # REVISION: --- -#=============================================================================== +#========================================================================= import os from . import Validation @@ -22,15 +22,17 @@ from configuration.Appconfig import Appconfig from . import Worker from PyQt4 import QtGui + class Kicad: """ This class called the Kicad Schematic,KicadtoNgspice Converter,Layout editor and Footprint Editor """ - def __init__(self,dockarea): + + def __init__(self, dockarea): self.obj_validation = Validation.Validation() self.obj_appconfig = Appconfig() - self.obj_dockarea= dockarea - + self.obj_dockarea = dockarea + def openSchematic(self): """ This function create command to open Kicad schematic @@ -38,58 +40,60 @@ class Kicad: print("Function : Open Kicad Schematic") self.projDir = self.obj_appconfig.current_project["ProjectName"] try: - self.obj_appconfig.print_info('Kicad Schematic is called for project ' + self.projDir) - except: - pass - #Validating if current project is available or not - + self.obj_appconfig.print_info( + 'Kicad Schematic is called for project ' + self.projDir) + except BaseException: + pass + # Validating if current project is available or not + if self.obj_validation.validateKicad(self.projDir): #print "calling Kicad schematic ",self.projDir self.projName = os.path.basename(self.projDir) - self.project = os.path.join(self.projDir,self.projName) - - #Creating a command to run - self.cmd = "eeschema "+self.project+".sch " + self.project = os.path.join(self.projDir, self.projName) + + # Creating a command to run + self.cmd = "eeschema " + self.project + ".sch " self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() - + else: self.msg = QtGui.QErrorMessage(None) - self.msg.showMessage('Please select the project first. You can either create new project or open existing project') - self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project') + self.msg.showMessage( + 'Please select the project first. You can either create new project or open existing project') + self.obj_appconfig.print_warning( + 'Please select the project first. You can either create new project or open existing project') self.msg.setWindowTitle("Error Message") - - + ''' - #Commenting as it is no longer needed as PBC and Layout will open from eeschema + #Commenting as it is no longer needed as PBC and Layout will open from eeschema def openFootprint(self): """ - This function create command to open Footprint editor + This function create command to open Footprint editor """ print "Kicad Foot print Editor called" self.projDir = self.obj_appconfig.current_project["ProjectName"] - try: - self.obj_appconfig.print_info('Kicad Footprint Editor is called for project : ' + self.projDir) + try: + self.obj_appconfig.print_info('Kicad Footprint Editor is called for project : ' + self.projDir) except: pass #Validating if current project is available or not - + if self.obj_validation.validateKicad(self.projDir): #print "calling Kicad FootPrint Editor ",self.projDir self.projName = os.path.basename(self.projDir) self.project = os.path.join(self.projDir,self.projName) - + #Creating a command to run self.cmd = "cvpcb "+self.project+".net " self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() - + else: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage('Please select the project first. You can either create new project or open existing project') self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project') self.msg.setWindowTitle("Error Message") - + def openLayout(self): """ This function create command to open Layout editor @@ -99,66 +103,67 @@ class Kicad: try: self.obj_appconfig.print_info('PCB Layout is called for project : ' + self.projDir) except: - pass + pass #Validating if current project is available or not if self.obj_validation.validateKicad(self.projDir): print "calling Kicad schematic ",self.projDir self.projName = os.path.basename(self.projDir) self.project = os.path.join(self.projDir,self.projName) - + #Creating a command to run self.cmd = "pcbnew "+self.project+".net " self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() - + else: - self.msg = QtGui.QErrorMessage(None) + self.msg = QtGui.QErrorMessage(None) self.msg.showMessage('Please select the project first. You can either create new project or open existing project') self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project') - self.msg.setWindowTitle("Error Message") - + self.msg.setWindowTitle("Error Message") + ''' - + def openKicadToNgspice(self): """ This function create command to call kicad to Ngspice converter. """ print("Function: Open Kicad to Ngspice Converter") - + self.projDir = self.obj_appconfig.current_project["ProjectName"] try: - self.obj_appconfig.print_info('Kicad to Ngspice Conversion is called') + self.obj_appconfig.print_info( + 'Kicad to Ngspice Conversion is called') self.obj_appconfig.print_info('Current Project is ' + self.projDir) - except: + except BaseException: pass - #Validating if current project is available or not + # Validating if current project is available or not if self.obj_validation.validateKicad(self.projDir): - #Cheking if project has .cir file or not + # Cheking if project has .cir file or not if self.obj_validation.validateCir(self.projDir): self.projName = os.path.basename(self.projDir) - self.project = os.path.join(self.projDir,self.projName) - - #Creating a command to run + self.project = os.path.join(self.projDir, self.projName) + + # Creating a command to run """ self.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py " +self.project+".cir " self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() """ - var=self.project+".cir" + var = self.project + ".cir" self.obj_dockarea.kicadToNgspiceEditor(var) - - - + else: self.msg = QtGui.QErrorMessage(None) - self.msg.showMessage('The project does not contain any Kicad netlist file for conversion.') - self.obj_appconfig.print_error('The project does not contain any Kicad netlist file for conversion.') - self.msg.setWindowTitle("Error Message") - + self.msg.showMessage( + 'The project does not contain any Kicad netlist file for conversion.') + self.obj_appconfig.print_error( + 'The project does not contain any Kicad netlist file for conversion.') + self.msg.setWindowTitle("Error Message") + else: self.msg = QtGui.QErrorMessage(None) - self.msg.showMessage('Please select the project first. You can either create new project or open existing project') - self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project') - self.msg.setWindowTitle("Error Message") - - \ No newline at end of file + self.msg.showMessage( + 'Please select the project first. You can either create new project or open existing project') + self.obj_appconfig.print_warning( + 'Please select the project first. You can either create new project or open existing project') + self.msg.setWindowTitle("Error Message") diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index b401e5e1..38d45495 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -1,23 +1,23 @@ -#=============================================================================== +#========================================================================= # # FILE: Validation.py -# -# USAGE: --- -# -# DESCRIPTION: This module is use to create validation for openProject,newProject and other activity. -# +# +# USAGE: --- +# +# DESCRIPTION: This module is use to create validation for openProject,newProject and other activity. +# # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. -# CREATED: Wednesday 12 February 2015 +# CREATED: Wednesday 12 February 2015 # REVISION: --- -#=============================================================================== +#========================================================================= import os -import re +import re import distutils.spawn @@ -27,108 +27,106 @@ class Validation: e.g if .proj is present in project directory or if new project name is already exist in workspace etc """ + def __init__(self): pass - - def validateOpenproj(self,projDir): + + def validateOpenproj(self, projDir): """ This function validate Open Project Information. """ print("Function: Validating Open Project Information") projName = os.path.basename(str(projDir)) - lookProj = os.path.join(str(projDir),projName+".proj") - #Check existence of project + lookProj = os.path.join(str(projDir), projName + ".proj") + # Check existence of project if os.path.exists(lookProj): return True else: return False - - - - def validateNewproj(self,projDir): + + def validateNewproj(self, projDir): """ This Project Validate New Project Information """ print("Function: Validating New Project Information") - - #Checking existence of project with same name + + # Checking existence of project with same name if os.path.exists(projDir): - return "CHECKEXIST" #Project with name already exist + return "CHECKEXIST" # Project with name already exist else: - #Check Proper name for project. It should not have space - if re.search(r"\s",projDir ): + # Check Proper name for project. It should not have space + if re.search(r"\s", projDir): return "CHECKNAME" else: return "VALID" - - def validateKicad(self,projDir): + + def validateKicad(self, projDir): """ This function validate if Kicad components are present """ print("FUnction : Validating for Kicad components") - if projDir == None: + if projDir is None: return False else: return True - - def validateCir(self,projDir): + + def validateCir(self, projDir): """ This function checks if ".cir" file is present. """ projName = os.path.basename(str(projDir)) - lookCir = os.path.join(str(projDir),projName+".cir") - #Check existence of project + lookCir = os.path.join(str(projDir), projName + ".cir") + # Check existence of project if os.path.exists(lookCir): return True else: return False - - def validateSub(self,subDir,givenNum): + + def validateSub(self, subDir, givenNum): """ This function checks if ".sub" file is present. """ subName = os.path.basename(str(subDir)) - lookSub = os.path.join(str(subDir),subName+".sub") - #Check existence of project + lookSub = os.path.join(str(subDir), subName + ".sub") + # Check existence of project if os.path.exists(lookSub): f = open(lookSub) - data=f.read() + data = f.read() f.close() - netlist=data.splitlines() + netlist = data.splitlines() for eachline in netlist: - eachline=eachline.strip() - if len(eachline)<1: + eachline = eachline.strip() + if len(eachline) < 1: continue - words=eachline.split() + words = eachline.split() if words[0] == '.subckt': - #The number of ports is specified in this line - #eg. '.subckt ua741 6 7 3' has 3 ports (6, 7 and 3). + # The number of ports is specified in this line + # eg. '.subckt ua741 6 7 3' has 3 ports (6, 7 and 3). numPorts = len(words) - 2 - print("Looksub : ",lookSub) - print("Given Number of ports : ",givenNum) - print("Actual Number of ports :",numPorts) + print("Looksub : ", lookSub) + print("Given Number of ports : ", givenNum) + print("Actual Number of ports :", numPorts) if numPorts != givenNum: return "PORT" else: return "True" else: return "DIREC" - - def validateCirOut(self,projDir): + + def validateCirOut(self, projDir): """ This function checks if ".cir.out" file is present. """ projName = os.path.basename(str(projDir)) - lookCirOut = os.path.join(str(projDir),projName+".cir.out") - #Check existence of project + lookCirOut = os.path.join(str(projDir), projName + ".cir.out") + # Check existence of project if os.path.exists(lookCirOut): return True else: return False - - def validateTool(self,toolName): + + def validateTool(self, toolName): """ This function check if tool is present in the system """ return distutils.spawn.find_executable(toolName) is not None - \ No newline at end of file diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py index f0fe7234..fe884ef3 100644 --- a/src/projManagement/Worker.py +++ b/src/projManagement/Worker.py @@ -1,4 +1,4 @@ -#=============================================================================== +#========================================================================= # # FILE: WorkerThread.py # @@ -14,29 +14,31 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Tuesday 24 Feb 2015 # REVISION: --- -#=============================================================================== +#========================================================================= from PyQt4 import QtCore import subprocess from configuration.Appconfig import Appconfig + class WorkerThread(QtCore.QThread): """ This is Thread class use to run the command """ - def __init__(self,args): + + def __init__(self, args): QtCore.QThread.__init__(self) self.args = args - def __del__(self): self.wait() def run(self): - print("Worker Thread Calling Command :",self.args) + print("Worker Thread Calling Command :", self.args) self.call_system(self.args) - def call_system(self,command): + def call_system(self, command): procThread = Appconfig() proc = subprocess.Popen(command.split()) procThread.procThread_list.append(proc) - procThread.proc_dict[procThread.current_project['ProjectName']].append(proc.pid) + procThread.proc_dict[procThread.current_project['ProjectName']].append( + proc.pid) diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index e8c81d6f..f01d2f53 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -1,109 +1,114 @@ -#=============================================================================== +#========================================================================= # # FILE: newProject.py -# -# USAGE: --- -# -# DESCRIPTION: It is called whenever new project is being called. -# +# +# USAGE: --- +# +# DESCRIPTION: It is called whenever new project is being called. +# # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. -# CREATED: Wednesday 12 February 2015 +# CREATED: Wednesday 12 February 2015 # REVISION: --- -#=============================================================================== +#========================================================================= from PyQt4 import QtGui from .Validation import Validation from configuration.Appconfig import Appconfig import os import json + class NewProjectInfo(QtGui.QWidget): """ This class is called when User create new Project. """ - + def __init__(self): super(NewProjectInfo, self).__init__() self.obj_validation = Validation() self.obj_appconfig = Appconfig() - - def createProject(self,projName): + def createProject(self, projName): """ This function create Project related directories and files """ #print "Create Project Called" - self.projName= projName + self.projName = projName self.workspace = self.obj_appconfig.default_workspace['workspace'] #self.projName = self.projEdit.text() - self.projName = str(self.projName).rstrip().lstrip() #Remove leading and trailing space - - self.projDir = os.path.join(self.workspace,str(self.projName)) - - - #Validation for newProject + # Remove leading and trailing space + self.projName = str(self.projName).rstrip().lstrip() + + self.projDir = os.path.join(self.workspace, str(self.projName)) + + # Validation for newProject if self.projName == "": self.reply = "NONE" else: self.reply = self.obj_validation.validateNewproj(str(self.projDir)) - - #Checking Validations Response + + # Checking Validations Response if self.reply == "VALID": - #create project directory + # create project directory try: os.mkdir(self.projDir) self.close() - self.projFile = os.path.join(self.projDir,self.projName+".proj") - f = open(self.projFile,"w") - except: + self.projFile = os.path.join( + self.projDir, self.projName + ".proj") + f = open(self.projFile, "w") + except BaseException: #print "Some Thing Went Wrong" self.msg = QtGui.QErrorMessage(self) - self.msg.showMessage('Unable to create project. Please make sure you have write permission on '+self.workspace) + self.msg.showMessage( + 'Unable to create project. Please make sure you have write permission on ' + + self.workspace) self.msg.setWindowTitle("Error Message") - f.write("schematicFile " + self.projName+".sch\n") + f.write("schematicFile " + self.projName + ".sch\n") f.close() - - #Now Change the current working project + + # Now Change the current working project newprojlist = [] #self.obj_appconfig = Appconfig() - self.obj_appconfig.current_project['ProjectName'] = self.projDir - newprojlist.append(self.projName+'.proj') + self.obj_appconfig.current_project['ProjectName'] = self.projDir + newprojlist.append(self.projName + '.proj') self.obj_appconfig.project_explorer[self.projDir] = newprojlist - - self.obj_appconfig.print_info('New project created : ' + self.projName) - self.obj_appconfig.print_info('Current project is : ' + self.projDir) - - json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath,'w')) + + self.obj_appconfig.print_info( + 'New project created : ' + self.projName) + self.obj_appconfig.print_info( + 'Current project is : ' + self.projDir) + + json.dump( + self.obj_appconfig.project_explorer, open( + self.obj_appconfig.dictPath, 'w')) return self.projDir, newprojlist - + elif self.reply == "CHECKEXIST": #print "Project already exist" self.msg = QtGui.QErrorMessage(self) - self.msg.showMessage('The project "'+self.projName+'" already exist.Please select the different name or delete existing project') + self.msg.showMessage( + 'The project "' + + self.projName + + '" already exist.Please select the different name or delete existing project') self.msg.setWindowTitle("Error Message") - - + elif self.reply == "CHECKNAME": #print "Name is not proper" self.msg = QtGui.QErrorMessage(self) - self.msg.showMessage('The project name should not contain space between them') + self.msg.showMessage( + 'The project name should not contain space between them') self.msg.setWindowTitle("Error Message") - + elif self.reply == "NONE": #print "Empty Project Name" self.msg = QtGui.QErrorMessage(self) self.msg.showMessage('The project name cannot be empty') self.msg.setWindowTitle("Error Message") - + def cancelProject(self): self.close() - - - - - \ No newline at end of file diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index c71d2181..58a6be0a 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -1,21 +1,21 @@ -#=============================================================================== +#========================================================================= # # FILE: openProject.py -# -# USAGE: --- -# -# DESCRIPTION: It is called whenever new project is being called. -# +# +# USAGE: --- +# +# DESCRIPTION: It is called whenever new project is being called. +# # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Fahim Khan, fahim.elex@gmail.com # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. -# CREATED: Wednesday 12 February 2015 +# CREATED: Wednesday 12 February 2015 # REVISION: --- -#=============================================================================== +#========================================================================= from PyQt4 import QtGui from .Validation import Validation @@ -28,45 +28,47 @@ 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): self.obj_Appconfig = Appconfig() self.openDir = self.obj_Appconfig.default_workspace["workspace"] - self.projDir=QtGui.QFileDialog.getExistingDirectory(self,"open",self.openDir) - + self.projDir = QtGui.QFileDialog.getExistingDirectory( + self, "open", self.openDir) + if self.obj_validation.validateOpenproj(self.projDir) == True: - self.obj_Appconfig.current_project['ProjectName'] = str(self.projDir) + self.obj_Appconfig.current_project['ProjectName'] = str( + self.projDir) if os.path.isdir(self.projDir): print("true") - - for dirs, subdirs, filelist in os.walk(self.obj_Appconfig.current_project["ProjectName"]): + + for dirs, subdirs, filelist in os.walk( + self.obj_Appconfig.current_project["ProjectName"]): directory = dirs files = filelist self.obj_Appconfig.project_explorer[dirs] = filelist - json.dump(self.obj_Appconfig.project_explorer, open(self.obj_Appconfig.dictPath,'w')) + json.dump( + self.obj_Appconfig.project_explorer, open( + self.obj_Appconfig.dictPath, 'w')) self.obj_Appconfig.print_info('Open Project called') self.obj_Appconfig.print_info('Current Project is ' + self.projDir) return dirs, filelist - + else: - self.obj_Appconfig.print_error("The project doesn't contain .proj file. Please select the proper directory else you won't be able to perform any operation") - reply = QtGui.QMessageBox.critical(None, "Error Message",''' Error: The project doesn't contain .proj file.
- Please select the proper project directory else you won't be able to perform any operation''',QtGui.QMessageBox.Ok|QtGui.QMessageBox.Cancel) - + self.obj_Appconfig.print_error( + "The project doesn't contain .proj file. Please select the proper directory else you won't be able to perform any operation") + reply = QtGui.QMessageBox.critical(None, "Error Message", ''' Error: The project doesn't contain .proj file.
+ Please select the proper project directory else you won't be able to perform any operation''', QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) + if reply == QtGui.QMessageBox.Ok: self.body() self.obj_Appconfig.print_info('Open Project called') - self.obj_Appconfig.print_info('Current Project is ' + self.projDir) + self.obj_Appconfig.print_info( + 'Current Project is ' + self.projDir) elif reply == QtGui.QMessageBox.Cancel: self.obj_Appconfig.print_info('No Project opened') else: pass - - - - - - \ No newline at end of file -- cgit From 818c3f2d43914940ba3cdf580c5a6f26a8200834 Mon Sep 17 00:00:00 2001 From: nilshah98 Date: Tue, 28 May 2019 00:27:24 +0530 Subject: projectManagement, ngspicetoModelica, subcircuit made pep8 compliant --- src/projManagement/Kicad.py | 53 ++++++++++++++++++++++++++------------- src/projManagement/Validation.py | 7 +++--- src/projManagement/Worker.py | 4 +-- src/projManagement/newProject.py | 30 +++++++++++----------- src/projManagement/openProject.py | 24 ++++++++++++------ 5 files changed, 73 insertions(+), 45 deletions(-) (limited to 'src/projManagement') diff --git a/src/projManagement/Kicad.py b/src/projManagement/Kicad.py index 2fc17615..2eaef643 100644 --- a/src/projManagement/Kicad.py +++ b/src/projManagement/Kicad.py @@ -1,4 +1,4 @@ -#========================================================================= +# ========================================================================= # # FILE: openKicad.py # @@ -14,7 +14,7 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Tuesday 17 Feb 2015 # REVISION: --- -#========================================================================= +# ========================================================================= import os from . import Validation @@ -25,7 +25,8 @@ from PyQt4 import QtGui class Kicad: """ - This class called the Kicad Schematic,KicadtoNgspice Converter,Layout editor and Footprint Editor + This class called the Kicad Schematic,KicadtoNgspice Converter,Layout + editor and Footprint Editor """ def __init__(self, dockarea): @@ -47,7 +48,7 @@ class Kicad: # Validating if current project is available or not if self.obj_validation.validateKicad(self.projDir): - #print "calling Kicad schematic ",self.projDir + # print "calling Kicad schematic ",self.projDir self.projName = os.path.basename(self.projDir) self.project = os.path.join(self.projDir, self.projName) @@ -59,13 +60,16 @@ class Kicad: else: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage( - 'Please select the project first. You can either create new project or open existing project') + 'Please select the project first. You can either create' + + 'new project or open existing project') self.obj_appconfig.print_warning( - 'Please select the project first. You can either create new project or open existing project') + 'Please select the project first. You can either create' + + 'new project or open existing project') self.msg.setWindowTitle("Error Message") ''' - #Commenting as it is no longer needed as PBC and Layout will open from eeschema + # Commenting as it is no longer needed as PBC and Layout will open from + # eeschema def openFootprint(self): """ This function create command to open Footprint editor @@ -73,7 +77,8 @@ class Kicad: print "Kicad Foot print Editor called" self.projDir = self.obj_appconfig.current_project["ProjectName"] try: - self.obj_appconfig.print_info('Kicad Footprint Editor is called for project : ' + self.projDir) + self.obj_appconfig.print_info('Kicad Footprint Editor is called' + + 'for project : ' + self.projDir) except: pass #Validating if current project is available or not @@ -90,8 +95,11 @@ class Kicad: else: self.msg = QtGui.QErrorMessage(None) - self.msg.showMessage('Please select the project first. You can either create new project or open existing project') - self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project') + self.msg.showMessage('Please select the project first. You can' + + 'either create new project or open existing project') + self.obj_appconfig.print_warning('Please select the project' + + 'first. You can either create new project or open existing' + + 'project') self.msg.setWindowTitle("Error Message") def openLayout(self): @@ -101,7 +109,8 @@ class Kicad: print "Kicad Layout is called" self.projDir = self.obj_appconfig.current_project["ProjectName"] try: - self.obj_appconfig.print_info('PCB Layout is called for project : ' + self.projDir) + self.obj_appconfig.print_info('PCB Layout is called for project : ' + + self.projDir) except: pass #Validating if current project is available or not @@ -117,8 +126,11 @@ class Kicad: else: self.msg = QtGui.QErrorMessage(None) - self.msg.showMessage('Please select the project first. You can either create new project or open existing project') - self.obj_appconfig.print_warning('Please select the project first. You can either create new project or open existing project') + self.msg.showMessage('Please select the project first. You can' + + 'either create new project or open existing project') + self.obj_appconfig.print_warning('Please select the project' + + 'first. You can either create new project or open existing' + + 'project') self.msg.setWindowTitle("Error Message") ''' @@ -145,7 +157,8 @@ class Kicad: # Creating a command to run """ - self.cmd = "python ../kicadtoNgspice/KicadtoNgspice.py " +self.project+".cir " + self.cmd = ("python ../kicadtoNgspice/KicadtoNgspice.py " + + "self.project+".cir ") self.obj_workThread = Worker.WorkerThread(self.cmd) self.obj_workThread.start() """ @@ -155,15 +168,19 @@ class Kicad: else: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage( - 'The project does not contain any Kicad netlist file for conversion.') + 'The project does not contain any Kicad netlist file for' + + 'conversion.') self.obj_appconfig.print_error( - 'The project does not contain any Kicad netlist file for conversion.') + 'The project does not contain any Kicad netlist file for' + + 'conversion.') self.msg.setWindowTitle("Error Message") else: self.msg = QtGui.QErrorMessage(None) self.msg.showMessage( - 'Please select the project first. You can either create new project or open existing project') + 'Please select the project first. You can either create' + + 'new project or open existing project') self.obj_appconfig.print_warning( - 'Please select the project first. You can either create new project or open existing project') + 'Please select the project first. You can either create' + + 'new project or open existing project') self.msg.setWindowTitle("Error Message") diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index 38d45495..11cdcaf9 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -1,11 +1,12 @@ -#========================================================================= +# ========================================================================= # # FILE: Validation.py # # USAGE: --- # -# DESCRIPTION: This module is use to create validation for openProject,newProject and other activity. +# DESCRIPTION: This module is use to create validation for openProject, +# newProject and other activity. # # OPTIONS: --- # REQUIREMENTS: --- @@ -15,7 +16,7 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Wednesday 12 February 2015 # REVISION: --- -#========================================================================= +# ========================================================================= import os import re import distutils.spawn diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py index fe884ef3..65c67dde 100644 --- a/src/projManagement/Worker.py +++ b/src/projManagement/Worker.py @@ -1,4 +1,4 @@ -#========================================================================= +# ========================================================================= # # FILE: WorkerThread.py # @@ -14,7 +14,7 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Tuesday 24 Feb 2015 # REVISION: --- -#========================================================================= +# ========================================================================= from PyQt4 import QtCore import subprocess from configuration.Appconfig import Appconfig diff --git a/src/projManagement/newProject.py b/src/projManagement/newProject.py index f01d2f53..40d66003 100644 --- a/src/projManagement/newProject.py +++ b/src/projManagement/newProject.py @@ -1,5 +1,5 @@ -#========================================================================= +# ========================================================================= # # FILE: newProject.py # @@ -15,7 +15,7 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Wednesday 12 February 2015 # REVISION: --- -#========================================================================= +# ========================================================================= from PyQt4 import QtGui from .Validation import Validation from configuration.Appconfig import Appconfig @@ -37,10 +37,10 @@ class NewProjectInfo(QtGui.QWidget): """ This function create Project related directories and files """ - #print "Create Project Called" + # print "Create Project Called" self.projName = projName self.workspace = self.obj_appconfig.default_workspace['workspace'] - #self.projName = self.projEdit.text() + # self.projName = self.projEdit.text() # Remove leading and trailing space self.projName = str(self.projName).rstrip().lstrip() @@ -62,18 +62,19 @@ class NewProjectInfo(QtGui.QWidget): self.projDir, self.projName + ".proj") f = open(self.projFile, "w") except BaseException: - #print "Some Thing Went Wrong" + # print "Some Thing Went Wrong" self.msg = QtGui.QErrorMessage(self) self.msg.showMessage( - 'Unable to create project. Please make sure you have write permission on ' + - self.workspace) + 'Unable to create project. Please make sure you have' + + 'write permission on ' + + self.workspace) self.msg.setWindowTitle("Error Message") f.write("schematicFile " + self.projName + ".sch\n") f.close() # Now Change the current working project newprojlist = [] - #self.obj_appconfig = Appconfig() + # self.obj_appconfig = Appconfig() self.obj_appconfig.current_project['ProjectName'] = self.projDir newprojlist.append(self.projName + '.proj') self.obj_appconfig.project_explorer[self.projDir] = newprojlist @@ -89,23 +90,24 @@ class NewProjectInfo(QtGui.QWidget): return self.projDir, newprojlist elif self.reply == "CHECKEXIST": - #print "Project already exist" + # print "Project already exist" self.msg = QtGui.QErrorMessage(self) self.msg.showMessage( - 'The project "' + - self.projName + - '" already exist.Please select the different name or delete existing project') + 'The project "' + + self.projName + + '" already exist.Please select the different name or delete' + + ' existing project') self.msg.setWindowTitle("Error Message") elif self.reply == "CHECKNAME": - #print "Name is not proper" + # print "Name is not proper" self.msg = QtGui.QErrorMessage(self) self.msg.showMessage( 'The project name should not contain space between them') self.msg.setWindowTitle("Error Message") elif self.reply == "NONE": - #print "Empty Project Name" + # print "Empty Project Name" self.msg = QtGui.QErrorMessage(self) self.msg.showMessage('The project name cannot be empty') self.msg.setWindowTitle("Error Message") diff --git a/src/projManagement/openProject.py b/src/projManagement/openProject.py index 58a6be0a..6cdcbb38 100644 --- a/src/projManagement/openProject.py +++ b/src/projManagement/openProject.py @@ -1,5 +1,5 @@ -#========================================================================= +# ========================================================================= # # FILE: openProject.py # @@ -15,7 +15,7 @@ # ORGANIZATION: eSim team at FOSSEE, IIT Bombay. # CREATED: Wednesday 12 February 2015 # REVISION: --- -#========================================================================= +# ========================================================================= from PyQt4 import QtGui from .Validation import Validation @@ -39,7 +39,7 @@ class OpenProjectInfo(QtGui.QWidget): self.projDir = QtGui.QFileDialog.getExistingDirectory( self, "open", self.openDir) - if self.obj_validation.validateOpenproj(self.projDir) == True: + if self.obj_validation.validateOpenproj(self.projDir): self.obj_Appconfig.current_project['ProjectName'] = str( self.projDir) if os.path.isdir(self.projDir): @@ -47,8 +47,10 @@ class OpenProjectInfo(QtGui.QWidget): for dirs, subdirs, filelist in os.walk( self.obj_Appconfig.current_project["ProjectName"]): - directory = dirs - files = filelist + # directory = dirs + # files = filelist + # above 'directory' and 'files' variable never used + pass self.obj_Appconfig.project_explorer[dirs] = filelist json.dump( self.obj_Appconfig.project_explorer, open( @@ -59,9 +61,15 @@ class OpenProjectInfo(QtGui.QWidget): else: self.obj_Appconfig.print_error( - "The project doesn't contain .proj file. Please select the proper directory else you won't be able to perform any operation") - reply = QtGui.QMessageBox.critical(None, "Error Message", ''' Error: The project doesn't contain .proj file.
- Please select the proper project directory else you won't be able to perform any operation''', QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) + "The project doesn't contain .proj file. Please select the" + + "proper directory else you won't be able to perform any" + + "operation") + reply = QtGui.QMessageBox.critical(None, "Error Message", + '''Error: The project doesn't contain .proj file.
+ Please select the proper project directory else you won't + be able to perform any operation''', + QtGui.QMessageBox.Ok | + QtGui.QMessageBox.Cancel) if reply == QtGui.QMessageBox.Ok: self.body() -- cgit