-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
31 lines (25 loc) · 925 Bytes
/
utils.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
from datetime import timedelta, date
import json
def next_week(today):
"""
Gives back the week number and the days of the next week
"""
next_weekday = (0 - today.weekday()) % 7 # 0 represents Monday
next_monday = today + timedelta(days=next_weekday)
_, week_number, _ = next_monday.isocalendar()
return (week_number, map(lambda offset : next_monday + timedelta(offset), range(7)))
def load_config(file_name):
with open(file_name) as f:
return json.loads(f.read())
def load_jokes(file_name):
with open(file_name) as f:
return f.read().split('\n')
def modify_config(new_conf, file_name):
with open(file_name, 'w') as f:
f.write(json.dumps(new_conf))
def show_day(day):
days = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday', 'Sunday']
return days[day]
def is_friday():
return date.today().weekday() == 4