Created
June 28, 2014 11:58
-
-
Save kbro237/a3416bbdcc5b78c0ed8d to your computer and use it in GitHub Desktop.
AddContactNote.py
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
# Quickly add a note with a Cobook styled delimeter to a contact based on its abid (Apple ID) which can be chosen, for example, by Launch Center Pro. Try this url: | |
# pythonista://{{AddContactNote}}?action=run&argv=[contact-abid]&argv=[prompt:Note to add...] | |
import contacts | |
import sys | |
# get the apple id and new note for the contact from the url arguments | |
abid = int(sys.argv[1]) | |
newnote = sys.argv[2] | |
# find contact based on abid | |
target = contacts.get_person(abid) | |
# display contact in console | |
print 40 * '=' | |
print target.full_name | |
print 40 * '-' | |
# add note (with delimter if a previous note exists) to the top of the note field | |
if target.note: | |
target.note = newnote + '\n---\n' + target.note | |
else: | |
target.note = newnote | |
# commit the changes and print | |
contacts.save() | |
print target.note |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment