Advertisement
Guest User

find_todos

a guest
Mar 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. def get_todos(auth_token):
  2.     client = EvernoteClient(token=auth_token)
  3.     note_store = client.get_note_store()
  4.  
  5.     # search for notes which have #todo content
  6.     # see http://dev.evernote.com/doc/articles/search.php
  7.     notefilter = NoteStore.NoteFilter()
  8.     notefilter.words = '#todo'
  9.     spec = NoteStore.NotesMetadataResultSpec()
  10.     spec.includeTitle = True
  11.     note_list = note_store.findNotesMetadata(auth_token, notefilter, 0, 100, spec)
  12.     print 'Search for #todo found %d notes' % note_list.totalNotes
  13.  
  14.     # for each note, pull the #todo lines
  15.     todos = []
  16.     for note_search_result in note_list.notes:
  17.         # pull note content
  18.         note = note_store.getNote(
  19.             auth_token,
  20.             note_search_result.guid,
  21.             True,
  22.             False,
  23.             False,
  24.             False,
  25.         )
  26.  
  27.         # find <li>'s with #todo text and print
  28.         tree = ET.fromstring(note.content)
  29.         elems = tree.findall('.//li')
  30.         todo_elems = filter(lambda e: '#todo' in e.text, elems)
  31.         for elem in todo_elems:
  32.             s = '%s :: %s' % (note_search_result.title, elem.text)
  33.             print s
  34.             todos.append(s)
  35.  
  36.     return todos
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement