Created
February 8, 2014 22:10
-
-
Save derickfay/8891099 to your computer and use it in GitHub Desktop.
Python script to sort text by the dates in @Due(YYYY-MM-DD) tags. Made for use with TaskPaper files.
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 | |
# first & only argument is the text to be parsed | |
theText = sys.argv[1] | |
theList=[] | |
j="" | |
for i in theText.splitlines(): | |
match = re.search('@due\(\d\d\d\d\-\d\d\-\d\d\)',i) | |
if match: | |
theKey = i[i.find('@due(')+5:i.find('@due(')+15] | |
else: | |
theKey ='' | |
theList = theList + [(theKey, i)] | |
for i in sorted(theList): | |
j = j+i[1]+"\n" | |
j = j[:-1] | |
print j |
Author
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