-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwhere_should_i_be_up_to.py
executable file
·55 lines (46 loc) · 1.46 KB
/
where_should_i_be_up_to.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
#!/usr/bin/env python3
# Tells me what page I should be up to by the end of the day.
# Can take an offset. Will not check for silly offsets like -1000.
from datetime import date
from sys import argv, exit
from math import ceil
def printUsage():
print("USAGE: {} <schedule or offset>".format(argv[0]))
print(" <schedule>: \"rev\" or \"orig\". \"rev\" is default.")
print(" <offset>: +n or -n. n must be an integer number of pages.")
exit(1)
def getOffset(arg1):
try:
offset = int(arg1[1:])
if arg1[0] == "-":
offset = -offset
except:
printUsage()
return offset
endDate = date(2017, 1, 5)
offset = 0
# I stopped for a few days and fell too far behind, so this
# is a revised schedule which omits the last 2 chapters.
if len(argv) == 1:
argv.append("rev")
if len(argv) not in (1,2):
printUsage()
if "+" in argv[1] or "-" in argv[1]:
offset = getOffset(argv[1])
argv[1] = "rev"
if argv[1] == "revised" or argv[1] == "rev":
startDate = date(2016, 12, 18)
startPage = 405
endPage = 742
elif argv[1] == "original" or argv[1] == "orig":
startDate = date(2016, 11, 27)
startPage = 90
endPage = 844
else:
printUsage()
# We calculate the pageChunk now, instead of specifying it in advance.
# It should still be 20 regardless of which of the dates/pages you choose.
pageChunk = ceil((endPage - startPage) / (endDate - startDate).days)
daysSinceStart = (date.today() - startDate).days + offset
target = startPage + daysSinceStart * pageChunk
print(target)