-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreminder_setup.py
More file actions
63 lines (55 loc) · 1.82 KB
/
Copy pathreminder_setup.py
File metadata and controls
63 lines (55 loc) · 1.82 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
import shelve
class shelveWith(object):
def __enter__(self,filey):
self.open(filey)
def __exit__(self, type, value, traceback):
self.close()
class assignment(object):
def __init__(self, name, due_date):
self.name = name
self.due_date = due_date
# date should be a tuple in format (MM, DD, YYYY)
class appointment(object):
def __init__(self, appointment_type, date, time, location):
self.type = appointment_type
self.time = time
# time should be a tuple in format(HH, MM, Bool)
self.date = date
# date should be a tuple in format (MM, DD, YYYY)
self.location = location
#save assignments based on their due_date. same handling method as appointments
def save_assignment(assignment):
f = shelve.open('assignment_db')
try:
f[assignment.due_date].append(assignment)
except KeyError:
f[assignment.due_date] = [assignment]
f.close()
# save appoiments based on their date
def save_appointment(appointment):
f = shelve.open('appointment_db')
try:
f[str(appointment.date)].append(appointment)
#if other appointments exist on this day, add it to that list
#otherwise, create a list for that date
except KeyError:
f[str(appointment.date)] = [appointment]
f.close()
# get tuple of assignment objects for a given due date
def get_assignment(date):
f = shelve.open('assignment_db')
try:
assignments = f[str(date)]
return assignments
except KeyError:
pass
f.close()
# get tuple of appointment objects for a given appointment date
def get_appointment(date):
f = shelve.open('appointment_db')
try:
appointments = f[str(date)]
return appointments
except KeyError:
pass
f.close()