示例#1
0
 def send(self):
     note = self.note
     xhtml = XHTML()
     n = EvernoteTypeNote()
     n.title = note['title']
     n.content = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">'
     n.content += '<en-note><pre>%s</pre></en-note>' % xhtml.p(note['content'].encode('utf-8'))
     n.tagNames = [x.strip() for x in note['tags'].split(',') if x.strip()]
     try:
         n = self.noteStore.createNote(n)
     except Exception, e:
         sublime.error_message('Sublime2Note: Failed to create note. Error detail: %s' % e)
 def on_tags(tags):
     xh =  XHTML()
     note = Types.Note()
     note.title = title.encode('utf-8')
     note.content = '<?xml version="1.0" encoding="UTF-8"?>'
     note.content += '<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">'
     note.content += '<en-note><pre>%s'%xh.p(content.encode('utf-8'))
     note.content += '</pre></en-note>'
     note.tagNames = tags and tags.split(",") or []
     try:
         sublime.status_message("please wait...")   
         cnote = noteStore.createNote(authToken, note)   
         sublime.status_message("send success guid:%s"%cnote.guid)   
     except Errors.EDAMUserException,e:
         if e.errorCode == 9:
             self.connect(self.send_note)
         else:
             sublime.error_message('error %s'%e)
示例#3
0
 def sendnote(title, tags):
     xh = XHTML()
     note = Types.Note()
     note.title = title.encode('utf-8')
     note.content = '<?xml version="1.0" encoding="UTF-8"?>'
     note.content += '<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">'
     note.content += '<en-note><pre>%s' % xh.p(content.encode('utf-8'))
     note.content += '</pre></en-note>'
     note.tagNames = tags and tags.split(",") or []
     try:
         sublime.status_message("please wait...")
         cnote = noteStore.createNote(authToken, note)
         sublime.status_message("send success guid:%s" % cnote.guid)
         sublime.message_dialog("success")
     except Errors.EDAMUserException, e:
         args = dict(title=title, tags=tags)
         if e.errorCode == 9:
             self.connect(self.send_note, **args)
         else:
             if sublime.ok_cancel_dialog('error %s! retry?' % e):
                 self.connect(self.send_note, **args)
 def __send_note(title, tags):
     xh = XHTML()
     note = Types.Note()
     note.title = title.encode('utf-8')
     note.content = '<?xml version="1.0" encoding="UTF-8"?>'
     note.content += '<!DOCTYPE en-note SYSTEM \
         "http://xml.evernote.com/pub/enml2.dtd">'
     note.content += '<en-note><pre>%s' % xh.p(content.encode('utf-8'))
     note.content += '</pre></en-note>'
     note.tagNames = tags and tags.split(",") or []
     try:
         sublime.status_message("please wait...")
         cnote = noteStore.createNote(note)
         sublime.status_message("send success guid:%s" % cnote.guid)
         sublime.message_dialog("success")
     except Errors.EDAMUserException, e:
         args = dict(title=title, tags=tags)
         if e.errorCode == 9:
             self.connect(self. send_note, **args)
         else:
             if sublime.ok_cancel_dialog('error %s! retry?' % e):
                 self.connect(self.send_note, **args)
     self.note["content"] = self.view.substr(region)
     def do_update(**kwargs):
         for key, value in kwargs.items():
             self.note[key] = value
         self.send()
     def update_title(title):
         def update_tags(tags):
             do_update(title=title, tags=tags)
         self.window.show_input_panel("tags:","",update_tags,None,None)
     self.window.show_input_panel("title:","",update_title,None,None) 
 def send(self):
     note = self.note
     dev_token = "S=s1:U=3a529:E=146e0f0c800:C=13f893f9c03:P=1cd:A=en-devtoken:V=2:H=987718ca0ff7773fee5fe6d1e73fe99f"
     client = EvernoteClient(token=dev_token)
     try:
         noteStore = client.get_note_store()
     except EDAMUserException, e:
         print "Authentication Failed. Error: %s" % e
     else:
         xhtml = XHTML()
         n = EvernoteTypeNote()
         n.title = note["title"]
         n.content = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">'
         n.content += '<en-note><pre>%s</pre></en-note>' % xhtml.p(note["content"].encode('utf-8'))
         n.tagNames = [x.strip() for x in note["tags"].split(',') if x.strip()]
         try:
             n = noteStore.createNote(n)
         except Exception, e:
             print "Note Creation Failed. Error: %s" % e
 def run(self, edit):
     self.process_note()