Skip to content

Instantly share code, notes, and snippets.

@wbsch
Created May 5, 2013 19:21
Show Gist options
  • Save wbsch/5521871 to your computer and use it in GitHub Desktop.
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 ;)
#!/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