Created
April 22, 2014 21:58
-
-
Save ciiqr/11195874 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import sys | |
import re | |
from enauath import client | |
from string import Template | |
#Accepts the GUID(string) of the note you want to append | |
def appendNote(guid): | |
#Get the note to be updated using the note's guid http://dev.evernote.com/documentation/reference/NoteStore.html#Fn_NoteStore_getNote | |
note = client.get_note_store().getNote(guid, True, True, False, False) | |
#Regular expressions used to replicate ENML tags. These same tags will be used to "rebuild" the note with the existing note metadata | |
xmlTag = re.search('<\?xml.*?>', note.content).group() | |
docTag = re.search('<\!DOCTYPE.*?>', note.content).group() | |
noteOpenTag = re.search('<\s*en-note.*?>', note.content).group() | |
noteCloseTag = re.search('<\s*/en-note.*?>', note.content).group() | |
breakTag = '<br />' | |
#Rebuild the note using the new content | |
content = note.content.replace(xmlTag, "").replace(noteOpenTag, "").replace(noteCloseTag, "").replace(docTag, "").strip() | |
content += breakTag + " ".join(sys.argv[1:]) | |
template = Template ('$xml $doc $openTag $body $closeTag') | |
note.content = template.substitute(xml=xmlTag,doc=docTag,openTag=noteOpenTag,body=content,closeTag=noteCloseTag) | |
#Update the note | |
client.get_note_store().updateNote(note) | |
#Return updated note (object) to the function | |
return note | |
noteGuid = "99fcbee2-3d3b-49e5-9686-ef808d07da15" | |
print appendNote(noteGuid) | |
This file contains hidden or 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
//Get Sandbox Dev Token - https://sandbox.evernote.com/api/DeveloperToken.action | |
//Get Account Dev Token - https://www.evernote.com/api/DeveloperToken.action | |
{ | |
"evernoteUser":{ | |
"sandbox_dev_token": "Enter Your Sandbox Dev Token", | |
"account_dev_token": "Enter Your Evernote Developer Token" | |
} | |
} |
This file contains hidden or 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
from evernote.api.client import EvernoteClient | |
import json | |
#Get the values for the sandbox dev token and evernote account dev token from the config file. | |
with open('config.json', 'r') as config_data: | |
data = json.load(config_data) | |
sandbox = data['evernoteUser']['sandbox_dev_token'] | |
account = data['evernoteUser']['account_dev_token'] | |
#client = EvernoteClient(token=sandbox, sandbox=True) | |
client = EvernoteClient(token=account, sandbox=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment