-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
173 lines (163 loc) · 7.04 KB
/
test.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
from classes import *
from datafunc import *
from main_func import *
filename_book = "/Users/ahmad/Desktop/Projects/Simple-Library-Software/Books.csv"
filename_person = "/Users/ahmad/Desktop/Projects/Simple-Library-Software/users.csv"
filename_data = "/Users/ahmad/Desktop/Projects/Simple-Library-Software/data.csv"
filename = "/Users/ahmad/Desktop/Projects/Simple-Library-Software/data.csv"
duetime = 14
a = parse_data(filename_book, filename_person, filename_data)
a.parse_books()
a.parse_person()
a.parse_data()
# takeout(a,13,15, filename)
# user_search_id(a, 15, filename)
# username_search(a, "test", filename)
# sendemail(a,"[email protected]", "sending email", "pass", 2, 15, datetime.now().date())
flag = True
print("Simple Library Software\n")
while flag:
print("Please enter help or h for help")
key1 = input("Input a command: ")
key1 = key1.lower()
if key1 == "h" or key1 == "help":
print("Commands:\n\tt or takeout - To sign out a book\n\tr or return - To sign in a book\n\tu or user - To search up a user\n\tq or quit - To quit the program\n\tb or book - To search books\n")
elif key1 == "q" or key1 == "quit":
print("GoodBye!")
flag = False
elif key1 == "r" or key1 == "return":
key1 = input("Would you like to use the student's username or id?: ")
key1 = key1.lower()
if key1 == "username":
username = input("Please enter the student's username: ")
id = None
for i in a.data_person:
if i.username == username:
id = i.pID
if id == None:
print("ERROR: Username NOT found!")
else:
bringtype = input("Would you like to use ISBN or the ID?: ")
bringtype = bringtype.lower()
if bringtype == "id":
bringid = input("Input the ID: ")
bringid = int(bringid)
bringback(a,int(bringid),int(id),filename)
elif bringtype == "isbn":
bringisbn = input("Input the ISBN: ")
bringisbn = int(bringisbn)
bringid = None
for i in a.data_books:
if len(i.data[3]) == 0:
continue
if int(i.data[3]) == bringisbn:
bringid = int(i.data[0])
if bringid == None:
print("Book not found")
else:
bringback(a,int(bringid),int(id),filename)
if key1 == "id":
id = input("Please enter the student's ID: ")
id = int(id)
if id > len(a.data_person):
print("ERROR: ID NOT found!")
else:
bringtype = input("Would you like to use ISBN or the ID?: ")
bringtype = bringtype.lower()
if bringtype == "id":
bringid = input("Input the ID: ")
bringid = int(bringid)
bringback(a,int(bringid),int(id),filename)
elif bringtype == "isbn":
bringisbn = input("Input the ISBN: ")
bringisbn = int(bringisbn)
bringid = None
for i in a.data_books:
if len(i.data[3]) == 0:
continue
elif int(i.data[3]) == bringisbn:
bringid = int(i.data[0])
if bringid == None:
print("Book not found")
else:
bringback(a,int(bringid),int(id),filename)
elif key1 == "t" or key1 == "takeout":
key1 = input("Would you like to use the student's username or id?: ")
key1 = key1.lower()
if key1 == "username":
username = input("Please enter the student's username: ")
id = None
for i in a.data_person:
if i.username == username:
id = i.pID
if id == None:
print("ERROR: Username NOT found!")
else:
bringtype = input("Would you like to use ISBN or the ID?: ")
bringtype = bringtype.lower()
if bringtype == "id":
bringid = input("Input the ID: ")
bringid = int(bringid)
takeout(a,int(bringid),int(id), duetime,filename)
elif bringtype == "isbn":
bringisbn = input("Input the ISBN: ")
bringisbn = int(bringisbn)
bringid = None
for i in a.data_books:
if len(i.data[3]) == 0:
continue
if int(i.data[3]) == bringisbn:
bringid = int(i.data[0])
if bringid == None:
print("Book not found")
else:
takeout(a,int(bringid),int(id), duetime,filename)
if key1 == "id":
id = input("Please enter the student's ID: ")
id = int(id)
if id > len(a.data_person):
print("ERROR: ID NOT found!")
else:
bringtype = input("Would you like to use ISBN or the ID?: ")
bringtype = bringtype.lower()
if bringtype == "id":
bringid = input("Input the ID: ")
bringid = int(bringid)
takeout(a,int(bringid),int(id),duetime,filename)
elif bringtype == "isbn":
bringisbn = input("Input the ISBN: ")
bringisbn = int(bringisbn)
bringid = None
for i in a.data_books:
if len(i.data[3]) == 0:
continue
elif int(i.data[3]) == bringisbn:
bringid = int(i.data[0])
if bringid == None:
print("Book not found")
else:
takeout(a,int(bringid),int(id),duetime,filename)
elif key1 == "u" or key1 == "user":
key1 = input("Would you like to use the student's username or id?: ")
key1 = key1.lower()
if key1 == "username":
username = input("Please enter the student's username: ")
username_search(a, username, filename)
elif key1 == "id":
id = input("Please enter the student's ID: ")
user_search_id(a, int(id), filename)
elif key1 == "b" or key1 == "book":
title = input("Please enter the title, or part of the title: ")
list_books = book_search(a,title)
for i in list_books:
print(i)
#TODO:
# Implement in main func
# Due dates:
# Implement Due dates - DONE
# Email - DONE
# Automate email:
# 2 Days before
# On the day
# After every week
# Start slowly implementing GUI