-
Notifications
You must be signed in to change notification settings - Fork 1
/
clock.py
40 lines (35 loc) · 1.13 KB
/
clock.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
class alarmclock:
def __init__(self, allResults):
for result in allResults:
if result.has_key("AlarmCommandKind"):
if result["AlarmCommandKind"] == "AlarmSetCommand":
self.setMultiple(result["NativeData"])
def setMultiple(self, nativeData):
if not nativeData.has_key("Alarms"):
print 'Could not find any alarms'
return
for alarmData in nativeData["Alarms"]:
self.setSingle(alarmData)
def setSingle(self, alarmData):
"""
given data in the form
{
"Hour":9,
"Title":"wake up",
"DaysOfWeek":[
],
"IsWake":True,
"InvalidDates":[
],
"Second":0,
"Minute":0
}
"""
hour = alarmData["Hour"]
minute = alarmData["Minute"]
second = alarmData["Second"]
if alarmData.has_key("Title"):
title = alarmData["Title"]
else:
title = ''
print "If I could I would set an alarm for "+str(hour)+":"+str(minute)+":"+str(second)+" and call it "+title+"."