-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_python.py
More file actions
281 lines (256 loc) · 10.5 KB
/
main_python.py
File metadata and controls
281 lines (256 loc) · 10.5 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
from datetime import *
from tabulate import tabulate
data_file = "Gym_database.txt"
gym_splits_1 = """1 - Three day split
Day 1: push day — chest, shoulders, triceps.
Day 2: pull day — back, biceps, forearms.
Day 3: legs day — quads, glutes, hamstrings, calves.
Day 4: push day — chest, shoulders, triceps.
Day 5: pull day — back, biceps, forearms.
Day 6: legs day — quads, glutes, hamstrings, calves.
Day 7: rest day\n\n"""
gym_splits_2 = """2 - Five-Day Split (recommended for beginners)
Day 1: Chest—4-5 exercises, 3-4 sets, 6-15 reps.
Day 2: Back— 5 exercises, 3-4 sets, 6-15 reps.
Day 3: Shoulders, upper traps— 4-5 exercises, 3-4 sets, 6-15 reps.
Day 4: Biceps, triceps— 3-4 exercises each, 3-4 sets, 6-15 reps.
Day 5: Legs— 5-6 exercises, 3-4 sets, 6-15 reps.
Day 6-7: Rest.\n\n"""
weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"]
def new_registration():
date_ = datetime.now()
day_name = date_.strftime("%A")
print(day_name, date_)
file_list = []
file = open(data_file, "r")
for line in file:
a = line.split("\t")
file_list.append(a)
file.close()
id = 1 + int(file_list[-1][0])
bmic = "--"
name = input("ENTER YOUR FULL NAME : ").strip().title()
dob = input("Enter your date of birth --> dd-mm-yyyy : ")
weight = input("Enter your weight (in kg) : ")
height = input("Enter your height (in cm) : ")
x = int(weight) / ((int(height)/100) ** 2)
if x < 18.5:
bmic = 'Underweight'
if (x >= 18.5) and (x < 25):
bmic = "Normal"
if (x >= 25) and (x < 30):
bmic = 'Overweight'
if x >= 30:
bmic = 'Obesity'
username = input("Create a USERNAME : ").strip().upper()
password = input("Create a password : ").strip().upper()
no_of_days = 0
print("Which gym split do you want to take? \n", gym_splits_1, gym_splits_2)
split_num = input("Enter 1 or 2 : ")
fee_status = "NOT PAID\n"
data_line = (str(id) + "\t" + name + "\t" + username + "\t" + password + "\t" + dob + "\t" + weight +
"\t" + height + "\t" + bmic + "\t" + day_name + "\t" + str(date_) + "\t" + str(no_of_days) + "\t" +
split_num + "\t" + fee_status)
file = open(data_file, 'a')
file.write(data_line)
file.close()
def read_all():
with open(data_file, "r") as file:
file_list = []
for line in file:
fields = line.strip().split("\t")
dob = fields[4]
age_ = calculate_age(dob)
file_list.append([
fields[0], # ID
fields[1], # Name
age_, # Age
fields[5] + " kg", # Weight
fields[6] + " cm", # Height
fields[7], # BMI
fields[9][:19], # Join Date
fields[10], # Days
"Split " + fields[11], # Split
fields[12].strip() # Fee status
])
headers = ["ID", "Name", "Age", "Weight", "Height", "BMI", "Join Date", "Days", "Split", "Fee Status"]
print(tabulate(file_list, headers=headers, tablefmt="fancy_grid"))
def today_game(x, y):
today = datetime.now().weekday()
if today == 6:
print("TODAY IS REST DAY ")
exit()
split_ = x
joining_day = y
splits_1 = ["push day — chest, shoulders, triceps.", "pull day — back, biceps, forearms."
, "legs day — quads, glutes, hamstrings, calves.", "push day — chest, shoulders, triceps."
, "pull day — back, biceps, forearms.", "legs day — quads, glutes, hamstrings, calves."
, "push day — chest, shoulders, triceps.", "pull day — back, biceps, forearms."
, "legs day — quads, glutes, hamstrings, calves.", "push day — chest, shoulders, triceps."
, "pull day — back, biceps, forearms.", "legs day — quads, glutes, hamstrings, calves."]
splits_2 = ["Chest—4-5 exercises, 3-4 sets, 6-15 reps."
, "Back— 5 exercises, 3-4 sets, 6-15 reps."
, "Shoulders, upper traps— 4-5 exercises, 3-4 sets, 6-15 reps."
, "Biceps, triceps— 3-4 exercises each, 3-4 sets, 6-15 reps."
, "Legs— 5-6 exercises, 3-4 sets, 6-15 reps.", "Rest day"
, "Chest—4-5 exercises, 3-4 sets, 6-15 reps."
, "Back— 5 exercises, 3-4 sets, 6-15 reps."
, "Shoulders, upper traps— 4-5 exercises, 3-4 sets, 6-15 reps."
, "Biceps, triceps— 3-4 exercises each, 3-4 sets, 6-15 reps."
, "Legs— 5-6 exercises, 3-4 sets, 6-15 reps.", "Rest day"]
if split_ == '1':
if joining_day == 'Monday':
print(splits_1[6 + today])
if joining_day == 'Tuesday':
print(splits_1[6 + today-1])
if joining_day == 'Wednesday':
print(splits_1[6 + today-2])
if joining_day == 'Thursday':
print(splits_1[6 + today-3])
if joining_day == 'Friday':
print(splits_1[6 + today-4])
if joining_day == 'Saturday':
print(splits_1[6 + today-5])
if split_ == '2':
if joining_day == 'Monday':
print(splits_2[6 + today])
if joining_day == 'Tuesday':
print(splits_2[6 + today-1])
if joining_day == 'Wednesday':
print(splits_2[6 + today-2])
if joining_day == 'Thursday':
print(splits_2[6 + today-3])
if joining_day == 'Friday':
print(splits_2[6 + today-4])
if joining_day == 'Saturday':
print(splits_2[6 + today-5])
def change_password(id, new_password):
file = open(data_file, "r")
n = 1 # var 'n' is made to count no. of lines
no_of_lines = 0
file_list = []
for line in file:
a = line.split("\t")
file_list.append(a)
no_of_lines = n
n += 1
file.close()
for i in range(no_of_lines):
if file_list[i][0] == id:
file_list[i][3] = new_password
break
# remove all text from the text file
file = open(data_file, "r+")
file.truncate(0)
file.close()
# updating text file
file = open(data_file, 'a')
for i in range(no_of_lines):
file.write(file_list[i][0] + "\t" + file_list[i][1] + "\t" + file_list[i][2] + "\t" +
file_list[i][3] + "\t" + file_list[i][4] + "\t" + file_list[i][5] + "\t" +
file_list[i][6] + "\t" + file_list[i][7] + "\t" + file_list[i][8] + "\t" +
file_list[i][9] + "\t" + file_list[i][10] + "\t" + file_list[i][11] +
"\t" + file_list[i][12])
file.close()
def attendance():
while True:
file = open(data_file, "r")
n = 1 # var 'n' is made to count no. of lines
no_of_lines = 0
file_list = []
for line in file:
a = line.split("\t")
file_list.append(a)
no_of_lines = n
n += 1
file.close()
id = input("Enter ID# (if many then separated by commas) : ").split(",")
for i in range(len(id)):
x = int(id[i])
y = int(file_list[x - 1][10])
y += 1
file_list[x - 1][10] = y
# remove all text from the text file
file = open(data_file, "r+")
file.truncate(0)
file.close()
# updating text file
file = open(data_file, 'a')
for i in range(no_of_lines):
file.write(file_list[i][0] + "\t" + file_list[i][1] + "\t" + file_list[i][2] + "\t" +
file_list[i][3] + "\t" + file_list[i][4] + "\t" + file_list[i][5] + "\t" +
file_list[i][6] + "\t" + file_list[i][7] + "\t" + file_list[i][8] + "\t" +
file_list[i][9] + "\t" + str(file_list[i][10]) + "\t" + file_list[i][11] +
"\t" + file_list[i][12])
file.close()
print("Successfully done !\n")
h = input(""" Enter 0 to close attendance app
or ENTER ANY number to again take attendance\n\t>>> """)
if int(h) == 0:
break
def fees_updated():
file = open(data_file, "r")
file_list = []
n = 1 # var 'n' is made to count no. of lines
no_of_lines = 0
for line in file:
a = line.split("\t")
file_list.append(a)
no_of_lines = n
n += 1
file.close()
# updated list
id_ = input("Enter ID# (if many then separated by commas) : ").split(",")
for i in range(len(id_)):
file_list[int(id_[i])-1][-1] = "'PAID'\n"
# remove all text from the text file
file = open(data_file, "r+")
file.truncate(0)
file.close()
# updating text file
file = open(data_file, 'a')
for i in range(no_of_lines):
file.write(file_list[i][0] + "\t" + file_list[i][1] + "\t" + file_list[i][2] + "\t" +
file_list[i][3] + "\t" + file_list[i][4] + "\t" + file_list[i][5] + "\t" +
file_list[i][6] + "\t" + file_list[i][7] + "\t" + file_list[i][8] + "\t" +
file_list[i][9] + "\t" + file_list[i][10] + "\t" + file_list[i][11] + "\t" + file_list[i][12])
file.close()
print("Successfully updated the fee status of the user !\n")
def fees_not_paid():
file = open(data_file, 'r')
for line in file:
full_line = line.split("\t")
id = full_line[0]
name = full_line[1]
fee_status = full_line[-1].strip()
if fee_status == "NOT PAID":
print("id # ", id, " NAME _ ", name)
file.close()
def age(dob):
day, month, year = dob.split("-")
day = int(day)
month = int(month)
year = int(year)
# CURRENT DATE
date_ = datetime.now().today()
current_day = date_.day
current_month = date_.month
current_year = date_.year
# CALCULATE AGE
if current_day < day:
current_day += 30
current_month -= 1
age_day = current_day - day
if current_month < month:
current_month += 12
current_year -= 1
age_month = current_month - month
age_year = current_year - year
age_ = ("YOUR AGE IS : " + str(age_year) + " years, " + str(age_month) + " months, " + str(age_day) + " days")
return age_
def calculate_age(dob):
day, month, year = map(int, dob.split("-"))
today = datetime.today()
age = today.year - year - ((today.month, today.day) < (month, day))
return f"{age} yrs"