-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
42 lines (39 loc) · 1.47 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import node
import os
# Initializing the filepaths
prompt_file = "promptsPS9.txt"
input_file = "inputPS9.txt"
def main():
"""This is the main function which reads the promptsPS9.txt and test the binary ATD"""
if not os.path.exists(prompt_file) or not os.path.exists(input_file):
print("inputPS9.txt or promptPS9.txt file not found.")
exit(1)
libraryTree = node.LibraryTree()
if libraryTree.getBookTitleCount(libraryTree.rootNode) == 0:
print("inputPS9.txt is empty")
exit(1)
with open(prompt_file, "r") as f:
lines = f.readlines()
if len(lines) == 0:
"promptPS9.txt is empty"
exit(1)
for line in lines:
line.strip()
if "check" in line:
line = line.split(':')
libraryTree._chkInChkOut(int(line[1]), line[0])
elif "ListTopBooks" in line:
libraryTree._getTopBooks(libraryTree.rootNode)
elif "BooksNotIssued" in line:
libraryTree._notIssued(libraryTree.rootNode)
elif "ListStockOut" in line:
libraryTree._stockOut(libraryTree.rootNode)
elif "printInventory" in line:
libraryTree.printBooks(libraryTree.rootNode)
elif "findBook" in line:
line = line.split(':')
libraryTree._findBook(libraryTree.rootNode, int(line[1]))
else:
pass
if __name__ == "__main__":
main()