-
-
Save taglia/f627ea0dcfccdb334bee to your computer and use it in GitHub Desktop.
NoteToOrgInbox
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
# NoteToOrgInbox | |
# | |
# Create a note to be appended to the MobileOrg.org file | |
# Expects the title and body as arguments | |
import random | |
import datetime | |
import webbrowser | |
import urllib | |
# Utility functions to build UUIDs | |
def hexstring(length): | |
result = '' | |
for i in xrange(length): | |
result += hex(random.randrange(0,15))[-1] | |
return result | |
def uuid(): | |
return hexstring(8) + '-'+hexstring(4) + '-' + hexstring(4) + '-' + hexstring(4) + '-' + hexstring(32) | |
# Builds the note | |
output = '* TODO ' + urllib.unquote(sys.argv[1]) + '\n' | |
today = datetime.datetime.now().strftime('%Y-%m-%d %a %H:%M') | |
output += '['+today+']\n' | |
output += '** '+ urllib.unquote(sys.argv[2])+'\n' | |
output += '** Note ID: '+uuid() | |
output = urllib.quote(output) | |
# Sends the note back to Drafts | |
webbrowser.open('drafts://x-callback-url/create?text='+output+'&action=AppendToOrg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment