Created
May 5, 2013 19:21
-
-
Save wbsch/5521871 to your computer and use it in GitHub Desktop.
Filter Taskwarrior tasks completed before a certain time. Reads from STDIN, outputs to STDOUT. Backups recommended ;)
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
#!/usr/bin/env python | |
import re | |
import sys | |
import time | |
if len(sys.argv) < 2: | |
print "Example usage:" | |
print sys.argv[0], "2013-05-05 < ~/.task/completed.data > ~/.task/completed.data.tmp && mv ~/.task/completed.data.tmp ~/.task/completed.data" | |
sys.exit(1) | |
# Date before which entries are to be filtered out. | |
filter_date = time.mktime(time.strptime(sys.argv[1], "%Y-%m-%d")) | |
for line in sys.stdin: | |
m = re.match('.*(?:\[| )end:"([^"]+)"', line) | |
if m and int(m.group(1)) > filter_date: | |
sys.stdout.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment