-
Notifications
You must be signed in to change notification settings - Fork 49
/
get_birthday.py
46 lines (35 loc) · 1.04 KB
/
get_birthday.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
#!/bin/python
# -*- coding: utf-8 -*-
import time
import better_spoken_numbers as bsn
from apcontent import alarmpi_content
class birthday(alarmpi_content):
def build(self):
birthday = None
today = float(time.strftime("%m.%d"))
if self._birthday(today):
birthday = self._name()
if birthday is None:
birthday = self._default()
else:
birthday = 'Today is ' + birthday + 's birthday.'
if self.debug:
print birthday
self.content = birthday
def _default(self):
if 'default' in self.sconfig:
return self.sconfig['default']
else:
return ''
def _birthday(self, today):
if 'birthday' in self.sconfig:
return today == float(self.sconfig['birthday'])
else:
self.sconfig['name'] = "Birthday configuration problem. " + \
self._name() + \
" has no birthday configured."
return True
def _name(self):
if 'name' in self.sconfig:
return self.sconfig['name']
return 'Unconfigured name'