diff options
Diffstat (limited to 'src/projManagement/Validation.py')
-rw-r--r-- | src/projManagement/Validation.py | 98 |
1 files changed, 48 insertions, 50 deletions
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 |