Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Python script to sort text by the dates in @due(YYYY-MM-DD) tags. Made for use with TaskPaper files.
#!/usr/bin/env python
import re
import sys
# first & only argument is the text to be parsed
theText = sys.argv[1]
for i in theText.splitlines():
match ='@due\(\d\d\d\d\-\d\d\-\d\d\)',i)
if match:
theKey = i[i.find('@due(')+5:i.find('@due(')+15]
theKey =''
theList = theList + [(theKey, i)]
for i in sorted(theList):
j = j+i[1]+"\n"
j = j[:-1]
print j

derickfay commented Feb 8, 2014

I run this as an OS X Service using Automator's Run Shell Script action, which makes it accessible via right-click on the selected text.



derickfay commented Jan 23, 2015

  • Note to self (and everyone else) - remember to set Pass Input as arguments in Automator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment