update
This commit is contained in:
@@ -23,6 +23,20 @@ words = (journal_path / 'godword').read_text().strip().split('\n')
|
||||
godword = '\n'.join(' '.join(random.choice(words)
|
||||
for __ in range(10)) for _ in range(2))
|
||||
|
||||
def parse_tasks_file():
|
||||
result = []
|
||||
|
||||
tasks = (journal_path / 'tasks').read_text().splitlines()
|
||||
|
||||
for task in tasks:
|
||||
days, name = task.split(':')
|
||||
days = days.split(',')
|
||||
result.append((days, name))
|
||||
|
||||
return result
|
||||
|
||||
tasks_file = parse_tasks_file()
|
||||
|
||||
if not target_page.exists():
|
||||
Popen(
|
||||
['bash', str(script_path / 'backup-script.sh'), current_date+'.zip'],
|
||||
@@ -43,6 +57,16 @@ if not target_page.exists():
|
||||
block['message']
|
||||
))
|
||||
|
||||
tasks = []
|
||||
curr_day = {
|
||||
0: 'mo', 1: 'tu', 2: 'we', 3: 'th',
|
||||
4: 'fr', 5: 'sa', 6: 'su',
|
||||
}[datetime.now().weekday()]
|
||||
|
||||
for days, name in tasks_file:
|
||||
if curr_day in days:
|
||||
tasks.append(name)
|
||||
|
||||
parts = [
|
||||
f'# {target_page.stem}',
|
||||
f'Godword:\n{godword}',
|
||||
@@ -56,6 +80,14 @@ if not target_page.exists():
|
||||
)
|
||||
|
||||
parts.append(f'Notifications:\n{notifications_rendered}')
|
||||
|
||||
if tasks:
|
||||
tasks_rendered = '\n'.join(
|
||||
f'[-] {task}'
|
||||
for task in tasks
|
||||
)
|
||||
|
||||
parts.append(f'Tasks:\n{tasks_rendered}')
|
||||
|
||||
header = '\n\n'.join(parts) + '\n'
|
||||
target_page.write_text(header)
|
||||
|
||||
Reference in New Issue
Block a user