Created
August 9, 2014 11:40
-
-
Save lukasklein/5b16f1328dbc19ac2718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
LINES = [ | |
'ITLISBFAMPM', | |
'ACQUARTERDC', | |
'TWENTYFIVE<X', | |
'HALFBTEN<FTO', | |
'PASTERUNINE', | |
'ONESIXTHREE', | |
'FOURFIVE>TWO', | |
'EIGHTELEVEN', | |
'SEVENTWELVE', | |
'TEN>SEOCLOCK', | |
] | |
WORD_MAPPINGS = { | |
'IT': 'IT', | |
'IS': 'IS', | |
'TO': 'TO', | |
'PAST': 'PAST', | |
} | |
HOUR_MAPPINGS = { | |
1: 'ONE', | |
2: 'TWO', | |
3: 'THREE', | |
4: 'FOUR', | |
5: 'FIVE>', | |
6: 'SIX', | |
7: 'SEVEN', | |
8: 'EIGHT', | |
9: 'NINE', | |
10: 'TEN>', | |
11: 'ELEVEN', | |
12: 'TWELVE', | |
} | |
MINUTE_MAPPINGS = { | |
0: 'OCLOCK', | |
5: 'FIVE<', | |
10: 'TEN<', | |
15: 'QUARTER', | |
20: 'TWENTY', | |
25: 'TWENTYFIVE', | |
30: 'HALF', | |
} | |
class Color: | |
PURPLE = '\033[95m' | |
CYAN = '\033[96m' | |
DARKCYAN = '\033[36m' | |
BLUE = '\033[94m' | |
GREEN = '\033[92m' | |
YELLOW = '\033[93m' | |
RED = '\033[91m' | |
BOLD = '\033[1m' | |
UNDERLINE = '\033[4m' | |
END = '\033[0m' | |
def get_active(): | |
active = [WORD_MAPPINGS['IT'], WORD_MAPPINGS['IS']] | |
t = datetime.now().time() | |
minute = int(round(t.minute / 5.) * 5) | |
hour = t.hour | |
if hour > 12: | |
hour -= 12 | |
if minute > 30: | |
minute = 60 - minute | |
hour += 1 | |
if hour > 12: | |
hour = 1 | |
if minute != 0: | |
active.append(WORD_MAPPINGS['TO']) | |
else: | |
if minute != 0: | |
active.append(WORD_MAPPINGS['PAST']) | |
active.append(MINUTE_MAPPINGS[minute]) | |
active.append(HOUR_MAPPINGS[hour]) | |
return active | |
def print_graphical(): | |
active = get_active() | |
for line in LINES: | |
l = line | |
for a in active: | |
l = l.replace(a, '%s%s%s%s' % (Color.BOLD, Color.RED, a, Color.END)) | |
print l.replace('>', '').replace('<', '') | |
if __name__ == '__main__': | |
print_graphical() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment