diff options
author | anjalijaiswal08 | 2019-06-27 10:52:26 +0530 |
---|---|---|
committer | anjalijaiswal08 | 2019-06-27 12:43:21 +0530 |
commit | b6effcc4c38520de2459f428dd4c5dae1e76f71f (patch) | |
tree | 1f8f911b9753dd4a3206439149f8b9cf60786e6e | |
parent | 24148f36807eb1c5dbe6a6edb623e58313521534 (diff) | |
download | eSim-b6effcc4c38520de2459f428dd4c5dae1e76f71f.tar.gz eSim-b6effcc4c38520de2459f428dd4c5dae1e76f71f.tar.bz2 eSim-b6effcc4c38520de2459f428dd4c5dae1e76f71f.zip |
done
-rw-r--r-- | src/projManagement/Validation.py | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/projManagement/Validation.py b/src/projManagement/Validation.py index ebaea625..d270da6e 100644 --- a/src/projManagement/Validation.py +++ b/src/projManagement/Validation.py @@ -28,6 +28,7 @@ or if new project name is already exist in workspace etc class Validation: + """ Takes as input the path of the project and checks if projName.proj file exists @@ -205,11 +206,9 @@ class Validation: """ projName = os.path.basename(str(projDir)) fileName = projName[:-4] - req_line = ".ends" + " " + str(fileName) - f = open(projDir, 'r') - flag1 = False - flag2 = False + first = True + last_line = [] # Checks if file is empty or not. if os.stat(projDir).st_size == 0: @@ -217,27 +216,30 @@ class Validation: print("===================") return False - for line in f: - word = line.split(' ') - if word[0] == "*": - continue - if word[0] == ".subckt": - word = line.split(' ') - break + with open(projDir, 'r') as f: + for line in f: + word = line.split() + if len(word) == 0 or word[0][0] == "*": + continue + # print(word) + # print(word[0], word[1]) + if first: + if word[0] == ".subckt" and word[1] == fileName: + first = False + else: + print("First line not found") + return False + else: + last_line = word - if word[0] == ".subckt" and word[1] == fileName: - flag1 = True - else: + if first is True: + print("First line not found") return False - with open(projDir, 'r') as m: - lines = m.read().splitlines() - last_line = lines[-2] - - if req_line == last_line: - flag2 = True - - if flag1 is True and flag2 is True: + print(last_line) + if len(last_line) >= 2 and last_line[0] == ".ends" and \ + last_line[1] == fileName: return True + print("Last line not found") return False |