summaryrefslogtreecommitdiff
path: root/src/projManagement/Validation.py
diff options
context:
space:
mode:
authoranjalijaiswal082019-06-25 15:38:20 +0530
committeranjalijaiswal082019-06-27 12:27:37 +0530
commitbfcd31c7c14519d29cf5b2c813899fc63bc5cf32 (patch)
treedc91bf104b4b0d207326b23ee690e8e92a78f5ef /src/projManagement/Validation.py
parentb9957bac0e86410007b0b728e58edeca5aa52d85 (diff)
downloadeSim-bfcd31c7c14519d29cf5b2c813899fc63bc5cf32.tar.gz
eSim-bfcd31c7c14519d29cf5b2c813899fc63bc5cf32.tar.bz2
eSim-bfcd31c7c14519d29cf5b2c813899fc63bc5cf32.zip
Uploading Subcircuit feature added
Diffstat (limited to 'src/projManagement/Validation.py')
-rw-r--r--src/projManagement/Validation.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py
index 65103282..a3b12ecd 100644
--- a/src/projManagement/Validation.py
+++ b/src/projManagement/Validation.py
@@ -186,3 +186,48 @@ class Validation:
Example, nghdl, eeschema...
"""
return distutils.spawn.find_executable(toolName) is not None
+
+ def validateSubcir(self, projDir):
+ """
+ This function checks for valid format of .sub file.
+ Correct format of file is:
+ - File should start with **.subckt <filename>**
+ - End with **.ends <filename>**
+ Function is passed with the file of path it checks the
+ file line by line untill it get .subckt as its first word
+ and then check for second word is it <fileName> or not.
+
+ Then it checks for second last line if it is ".ends
+ <filename>" it return True if conditions satisfy else
+ return False.
+
+ """
+ projName = os.path.basename(str(projDir))
+ fileName = projName[:-4]
+ req_line = ".ends" + " " + str(fileName)
+ f = open(projDir, 'r')
+
+ flag1 = False
+ flag2 = False
+
+ for line in f:
+ word = line.split(' ')
+ if word[0] == "*":
+ continue
+ if word[0] == ".subckt":
+ break
+
+ if word[1] == fileName:
+ flag1 = True
+
+ with open(projDir, 'r') as m:
+ lines = m.read().splitlines()
+ last_line = lines[-2]
+
+ if req_line == last_line:
+ flag2 = True
+
+ if flag1 == True and flag2 == True:
+ return "True"
+ else:
+ return "False"