-
-
Save tomato42/183bb6f4153f394f347ce09e004b30eb to your computer and use it in GitHub Desktop.
Quick logging and reporting of performed tasks from this and last week
This file contains hidden or 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
#!/bin/bash | |
MYDIR=~/.local/share/idid | |
mkdir -p "$MYDIR" | |
echo $(date -u --iso-8601=seconds) $@ >> "$MYDIR"/log |
This file contains hidden or 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
#!/bin/python | |
from __future__ import print_function | |
import io | |
import sys | |
from dateutil import parser, relativedelta | |
import datetime | |
import pytz | |
import os.path | |
import textwrap | |
MYDIR="~/.local/share/idid/" | |
FILE="log" | |
path = os.path.expanduser(MYDIR + FILE) | |
tasks = [] | |
with io.open(path, 'r', encoding='utf-8') as fp: | |
for line in fp: | |
datestring, text = line.split(' ', 1) | |
text = text.strip() | |
text = "\n".join(textwrap.wrap( | |
text, width=75, | |
initial_indent=' * ', | |
subsequent_indent=' ', | |
break_long_words=False)) | |
date = parser.parse(datestring) | |
now = datetime.datetime.now(pytz.UTC) | |
start = now - datetime.timedelta((now.weekday() + 1) % 7) | |
if sys.argv[1:2] == ["last"]: | |
last_sun = start + \ | |
relativedelta.relativedelta(weekday=relativedelta.SU(-2)) | |
next_sun = start + \ | |
relativedelta.relativedelta(weekday=relativedelta.SU(-1)) | |
else: | |
last_sun = start + \ | |
relativedelta.relativedelta(weekday=relativedelta.SU(-1)) | |
next_sun = start + \ | |
relativedelta.relativedelta(weekday=relativedelta.SU(2)) | |
if last_sun < date < next_sun: | |
tasks.append(text) | |
print("* Tasks completed: {0}".format(len(tasks))) | |
for i in tasks: | |
print("{0}".format(i)) | |
print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment