-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrontSplitsTracker.py
More file actions
155 lines (107 loc) · 4.39 KB
/
FrontSplitsTracker.py
File metadata and controls
155 lines (107 loc) · 4.39 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
from datetime import datetime
def readUserDate(userID):
#create file if it doesn't exist
fcreate = open(userID + "Date.txt", "a")
fcreate.close()
#try to read the file
startDate = datetime.now()
fin = open(userID + "Date.txt", "r")
line = fin.readline()
if (len(line) > 0):
#File has contents, so read them
#print("Length of line is: " + str(len(line)))
startDate = datetime.fromtimestamp(float(line))
fin.close()
else:
#Create timestamp in our new file
fin.close()
fout = open(userID + "Date.txt", "w")
fout.write(str(startDate.timestamp()) + "\n")
fout.close()
print("Timestamp in the file is: " + str(startDate) + "\n")
return startDate
def readUserRightSplits(userID):
#create file if it doesn't exist
fcreate = open(userID + "RightSplits.txt", "a")
fcreate.close()
#try to read the file
rightSplitsStart = 0
fin = open(userID + "RightSplits.txt", "r")
line = fin.readline()
if (len(line) > 0):
#File has contents, so read them
rightSplitsStart = int(line)
fin.close()
return rightSplitsStart
def readUserLeftSplits(userID):
#create file if it doesn't exist
fcreate = open(userID + "LeftSplits.txt", "a")
fcreate.close()
#try to read the file
leftSplitsStart = 0
fin = open(userID + "LeftSplits.txt", "r")
line = fin.readline()
if (len(line) > 0):
#File has contents, so read them
leftSplitsStart = int(line)
fin.close()
return leftSplitsStart
# Ask the user for their user ID. If the the user ID does not exist, this is a
# new user.
print("Welcome to your front splits tracker!\n\n")
userID = input("Please enter your user ID: ")
# If this is a new user, create a new file based on their chosen ID and set
# a goal date for achievement of 180 degree splits. If this is not a new
# user, open thier existing file and read their data, displaying goal date
# and projected range of motion for current date.
userStartDate = readUserDate(userID)
userRightSplits = readUserRightSplits(userID)
userLeftSplits = readUserLeftSplits(userID)
newUser = False
#User enters splits angle in degrees if new account
if (userRightSplits == 0):
#Now we know this is a new user
newUser = True
startRS = input("Please enter the angle of your right splits in degrees: ")
userRightSplits = int(startRS)
startLS = input("Please enter the angle of your left splits in degrees: ")
userLeftSplits = int(startLS)
#save to file
#open the file and write right splits
fout = open(userID + "RightSplits.txt", "w")
fout.write(str(userRightSplits) + "\n")
fout.close()
#open the file and write left splits
fout = open(userID + "LeftSplits.txt", "w")
fout.write(str(userLeftSplits) + "\n")
fout.close()
print("Your starting right splits is: " + str(userRightSplits))
print("Your starting left splits is: " + str(userLeftSplits))
if (newUser == False):
# Ask for current data
newRS = int(input("Please enter your current right splits in degrees: "))
newLS = int(input("Please enter your current left splits in degrees: "))
improveRS = newRS - userRightSplits
improveLS = newLS - userLeftSplits
print("Your right splits have improved by " + str(improveRS) + " degrees.")
print("Your left splits have improved by " + str(improveLS) + " degrees.")
currentDate = datetime.now()
dateDifference = currentDate - userStartDate
#print("dateDifference: " + str(dateDifference))
daysSinceStart = int(dateDifference.days)
#print("daysSinceStart: " + str(daysSinceStart))
degreesToGoRS = 180 - newRS
#print("degreesToGoRS: " +str(degreesToGoRS))
degreesToGoLS = 180 - newLS
if (improveRS > 0):
rateRS = daysSinceStart/improveRS
daysToRS = rateRS * degreesToGoRS
print("At this rate of improvement, you will achieve your full right splits in " + str(int(daysToRS)) + " days.")
else:
print("You have not seen any improvement in you right splits. Please keep trying.")
if (improveLS > 0):
rateLS = daysSinceStart/improveLS
daysToLS = rateLS * degreesToGoLS
print("At this rate of improvement, you will achieve your full left splits in " + str(int(daysToLS)) + " days.")
else:
print("You have not seen any improvement in you left splits. Please keep trying.")