def process_goal_updates(self, stored_goal_states):
        note_filter = NoteFilter()

        # Get all the goals
        for notebook in self.get_note_store().listNotebooks():

            if notebook.name not in ["Backlog","Current","Complete","Dropped"]:
                continue

            note_filter.notebookGuid = notebook.guid

            note_metadata_list = self.get_all_notes_metadata(self.auth_token,note_filter,NoteStore.NotesMetadataResultSpec())

            # For each goal
            for note_metadata in note_metadata_list:

                # Check if the goal is new or has changed state (moved from another notebook)
                if note_metadata.guid in stored_goal_states[notebook.name]:
                    # the goal is in the same state as it was the last time we checked
                    continue
                else:
                    # the goal is new, or it has changed state
                    # search to see if it was previously in a different notebook
                    other_notebooks = ["Backlog","Current","Complete","Dropped"]
                    other_notebooks.remove(notebook.name)

                    goal_has_moved = None

                    for previous_notebook in other_notebooks:
                        if note_metadata.guid in stored_goal_states[previous_notebook]:
                            # We know the note used to be in this notebook, so annotate the note and update what we know

                            annotation = (datetime.now()-timedelta(days=1)).strftime("%Y-%m-%d") \
                                                        + " Moved from " + previous_notebook \
                                                        + " to " + notebook.name
                            self.annotate_note(note_metadata.guid,annotation,False)

                            stored_goal_states[previous_notebook].remove(note_metadata.guid)
                            stored_goal_states[notebook.name].append(note_metadata.guid)

                            goal_has_moved = True
                            break

                    if goal_has_moved is None:
                        # The note has been newly added
                        # So annotate the note and save the state of the note locally

                        annotation = (datetime.now()-timedelta(days=1)).strftime("%Y-%m-%d") \
                                                        + " Added to " + notebook.name
                        self.annotate_note(note_metadata.guid,annotation,True)

                        stored_goal_states[notebook.name].append(note_metadata.guid)

        return stored_goal_states
Example #2
0
 def getnotes(self,auth_token, nb_guid, fun):
     spec = NotesMetadataResultSpec()
     spec.includeTitle=True
     filter=NoteFilter()
     filter.notebookGuid=nb_guid
     note_store = self.client.get_note_store()
     notelist = []
     for i in range(0,500,250):
         notes = note_store.findNotesMetadata(auth_token, filter, i, i+250, spec)
         notelist.extend([fun(n) for n in notes.notes])
     return notelist
Example #3
0
 def getNotesInNotebook(self, wanted_notebook):
     filter = NoteFilter()
     updated_filter = NoteFilter(words='evernote')
     filter.notebookGuid = wanted_notebook.guid;
     offset = 0
     max_notes = 10
     result_spec = NotesMetadataResultSpec(includeTitle=True)
     #notes = note_store.findNotes(auth_token, filter, offset, max_notes);
     notes_data = self.note_store.findNotesMetadata(auth_token, filter, offset, max_notes, result_spec);
     notes = notes_data.notes
     return notes
Example #4
0
 def getnotes(self, auth_token, nb_guid, fun):
     spec = NotesMetadataResultSpec()
     spec.includeTitle = True
     filter = NoteFilter()
     filter.notebookGuid = nb_guid
     note_store = self.client.get_note_store()
     notelist = []
     for i in range(0, 500, 250):
         notes = note_store.findNotesMetadata(auth_token, filter, i,
                                              i + 250, spec)
         notelist.extend([fun(n) for n in notes.notes])
     return notelist
Example #5
0
    def list_notes(self, notebook):
        # ノート検索条件を指定。ノートブックのIDを指定。更新日でソート
        note_filter = NoteFilter()
        note_filter.notebookGuid = notebook.guid
        note_filter.order = NoteSortOrder.UPDATED

        # ノート検索結果のフォーマットを指定。タイトルを含む
        result_format = NotesMetadataResultSpec()
        result_format.includeTitle = True

        # ノートのメタデータリストを取得
        note_meta_list = self.note_store.findNotesMetadata(note_filter, 0, 10, result_format)
        return [Note(self, note_meta) for note_meta in note_meta_list.notes]
Example #6
0
    def sync_notebook_notes(self, notebook):
        if not self.should_sync_notebook_notes(notebook):
            return

        logging.info('sync notebook: ' + notebook.name)
        note_filter = NoteFilter()
        note_filter.notebookGuid = notebook.guid

        note_list = []
        current_offset = 0
        while True:
            logging.info('sync notebook: ' + notebook.name + ' - ' +
                         str(current_offset))
            note_batch = self.note_store.findNotes(note_filter, current_offset,
                                                   NOTES_LOAD_BATCH_SIZE + 1)
            if len(note_batch.notes) < NOTES_LOAD_BATCH_SIZE + 1:
                note_list += note_batch.notes
                break
            else:
                note_list += note_batch.notes[:-1]
                current_offset += NOTES_LOAD_BATCH_SIZE

        if notebook.guid in self.notebook_notes:
            prev_notes = self.notebook_notes[notebook.guid].copy()
        else:
            prev_notes = {}
        new_notes = {}

        for note in note_list:
            new_notes[note.guid] = note
            if note.guid not in prev_notes:
                logging.info('sync new note: ' + note.title)
                self.add_notebook_note_to_fuse(note)
            elif note.title != prev_notes[note.guid].title:
                logging.info('sync note renamed: ' +
                             prev_notes[note.guid].title + '->' + note.title)
                self.rename_notebook_note_in_fuse(note.notebookGuid,
                                                  prev_notes[note.guid].title,
                                                  note.title)

        for prev_note_guid, prev_note in prev_notes.items():
            if prev_note_guid not in new_notes:
                logging.info('sync: note deleted: ' + prev_note.name)
                self.remove_notebook_note_from_fuse(prev_note.notebookGuid,
                                                    prev_note_guid)

        self.notebook_notes[notebook.guid] = new_notes
        logging.info('sync notebook - done: ' + notebook.name)
        self.notebooks_notes_sync_time[notebook.guid] = time()
Example #7
0
def get_notes(userStore, noteStore):
    guid = get_site_notebook().guid
    published_guid = get_published_tag(guid)

    note_filter = NoteFilter()
    note_filter.notebookGuid = guid
    note_filter.order = NoteSortOrder.CREATED
    note_filter.tagGuids = [published_guid]
    spec = NotesMetadataResultSpec(includeTitle=True,
                                   includeCreated=True,
                                   includeUpdated=True,
                                   includeNotebookGuid=True,
                                   includeTagGuids=True)
    notes = noteStore.findNotesMetadata(note_filter, 0, 100, spec).notes
    return notes
def process_notebook(notebook, note_store, user):

    print_info("Processing notebook:" + notebook.name)

    note_filter = NoteFilter(order=NoteSortOrder.TITLE)
    note_filter.notebookGuid = notebook.guid
    result_spec = NotesMetadataResultSpec(includeTitle=True)
    result_list = note_store.findNotesMetadata(note_filter, 0, MAX_NOTES, result_spec)

    notes = []
    for note in result_list.notes:
        notes.append({
            'title': note.title,
            'link':  generate_note_link(user, note)
        })

    return notes
Example #9
0
def iterate_through_evernote(evernote_lists,noteStore,google_lists,google_auth):
	evernote_dev_token = 'S=s317:U=2a12764:E=14524e2f945:C=13dcd31cd47:P=1cd:A=en-devtoken:V=2:H=4ae170cd15a53f88d0b2150c23fcae0b'
	notebooks = noteStore.listNotebooks()
	for i in notebooks:
		filter = NoteFilter()
		filter.notebookGuid = i.guid
		notes = noteStore.findNotes(evernote_dev_token,filter,0,100)
		notebook_name = ''
		if i.name == "gophersbball17's notebook":
			notebook_name = "testing55318's list"
		else:
			notebook_name = i.name
		google_guid = google_lists[1][google_lists[0].index(notebook_name)]
		gList = get_google_list_items(google_guid)
		for n in notes.notes:
			if n.title not in gList:
				create_google_list_item(google_guid,n.title,google_auth)
Example #10
0
    def runBackup(self):
        self.initClient()

        notebooks = self.noteStore.listNotebooks(self.token)

        notebookIndex = 0
        for notebook in notebooks:
            self.progressHandler.startTask('Backing up notebook ' +
                                           notebook.name)

            filt = NoteFilter()
            filt.notebookGuid = notebook.guid
            notelist = self.noteStore.findNotes(self.token, filt, 0, 100)

            if not len(notelist.notes): continue

            notes = []

            self.progressHandler.startTask('Notebook: ' + notebook.name)

            i = 0
            for note in notelist.notes:
                i += 1
                notes.append(self.getNote(notebook.name, note.guid))

                notesProgress = float(i) / len(notelist.notes) / len(notebooks)
                notebookProgress = float(notebookIndex) / len(notebooks)
                self.progressHandler.setProgress(notesProgress +
                                                 notebookProgress)

            if self.add_note_files:
                for note in notes:
                    filename = note['title'] + '.xml'
                    self.output.set(filename,
                                    note['content_raw'],
                                    bucket=notebook.name + '/notes')

            if self.create_json:
                jsonData = json.dumps(notes)
                self.output.set('data.json', jsonData, bucket=notebook.name)

            if self.create_csv:
                self.writeCsvData(notebook.name, 'data.csv', notes)

            notebookIndex += 1
Example #11
0
def get_evernote_list_items(noteStore):
	evernote_dev_token = 'S=s317:U=2a12764:E=14524e2f945:C=13dcd31cd47:P=1cd:A=en-devtoken:V=2:H=4ae170cd15a53f88d0b2150c23fcae0b'
	dict = {}
	notebooks = noteStore.listNotebooks()
	for i in notebooks:
		filter = NoteFilter()
		filter.notebookGuid = i.guid
		notes = noteStore.findNotes(evernote_dev_token,filter,0,100)
		notebook_name = ''
		if i.name == "gophersbball17's notebook":
			notebook_name = "testing55318's list"
		else:
			notebook_name = i.name
		note_names = [i.guid]
		for n in notes.notes:
			note_names.append(n.title)
		dict[notebook_name] = note_names
	return dict
Example #12
0
def get_ev_notes():
    dev_token = app.config['EN_DEV_TOKEN']
    notestore_url = app.config['EN_NOTESTORE_URL']
    nb_guid = app.config['EN_NB_GUID']

    client = EvernoteClient(token=dev_token)
    note_store = client.get_note_store()

    filt = NoteFilter()
    filt.notebookGuid = nb_guid

    spec = NotesMetadataResultSpec()
    spec.includeTitle = True

    notemetalist = note_store.findNotesMetadata(dev_token, filt, 0, 100, spec)
    notes = []
    for note_data in notemetalist.notes:
        note = note_store.getNote(dev_token, note_data.guid, True, True, True,
                                  True)

        title = note.title
        author = note.attributes.author
        date = note.updated
        url = note.attributes.sourceURL
        cont = note.content
        note_tags = []

        tag_guids = note.tagGuids
        if tag_guids is not None:
            for tag_guid in tag_guids:
                tag = note_store.getTag(dev_token, tag_guid)
                note_tags.append({'guid': tag_guid, 'name': tag.name})

        notes.append({
            'guid': note_data.guid,
            'title': title,
            'date_modified': date,
            'author': author,
            'content': cont,
            'tags': note_tags
        })

    #print notes
    return dumps(notes)
Example #13
0
def getFirstNoteBook():

    userStore = client.get_user_store()
    noteStore = client.get_note_store()
    note = noteStore.listNotebooks()
    user = userStore.getUser()

    firstNotebook = note[0]
    global firstID
    firstID = firstNotebook.guid

    print (" ")
    print ("First notebook in the stack")
    print firstNotebook.name
    print firstID

    print (" ")

    print " Notes in " + firstNotebook.name

    # filter = NoteFilter()
    # filter.notebookGuid = firstID
    # filter.order = Types.NoteSortOrder.UPDATED
    # filter.ascending = False

    updated_filter = NoteFilter(order=NoteSortOrder.UPDATED)
    updated_filter.notebookGuid = firstID
    offset = 0
    max_notes = 10
    result_spec = NotesMetadataResultSpec(includeTitle=True)
    result_list = noteStore.findNotesMetadata(dev_token, updated_filter, offset, max_notes, result_spec)

    # note is an instance of NoteMetadata
    # result_list is an instance of NotesMetadataList

    for note in result_list.notes:
        print note.title
        notesContents[note.title] = noteStore.getNoteContent(note.guid)

    allNotes.append(note)

    print (" ")
    print ("Username")
    print user.username
Example #14
0
  def runBackup(self):
    self.initClient()

    notebooks = self.noteStore.listNotebooks(self.token)
    
    notebookIndex = 0
    for notebook in notebooks:
      self.progressHandler.startTask('Backing up notebook ' + notebook.name)

      filt = NoteFilter()
      filt.notebookGuid = notebook.guid
      notelist = self.noteStore.findNotes(self.token, filt, 0, 100)

      if not len(notelist.notes): continue

      notes = []

      self.progressHandler.startTask('Notebook: ' + notebook.name)

      i = 0
      for note in notelist.notes:
        i += 1
        notes.append(self.getNote(notebook.name, note.guid))
        
        notesProgress = float(i) / len(notelist.notes) / len(notebooks)
        notebookProgress = float(notebookIndex) / len(notebooks)
        self.progressHandler.setProgress(notesProgress + notebookProgress)

      if self.add_note_files:
        for note in notes:
          filename = note['title'] + '.xml'
          self.output.set(filename, note['content_raw'],
            bucket=notebook.name + '/notes')

      if self.create_json:
        jsonData = json.dumps(notes)
        self.output.set('data.json', jsonData, bucket=notebook.name)

      if self.create_csv:
        self.writeCsvData(notebook.name, 'data.csv', notes)
      
      notebookIndex += 1
    def get_note_filter(self,start_time,notebook_name,end_time=None):

        for notebook in self.get_note_store().listNotebooks():
            if notebook.name == notebook_name:
                event_notebook_guid = notebook.guid
                break

        if event_notebook_guid is None:
            raise EvernoteConnectorException("Unable to find a notebook with the name '" + notebook_name + "'")

        note_filter = NoteFilter()
        note_filter.order = NoteSortOrder.CREATED
        note_filter.ascending = True
        note_filter.notebookGuid = event_notebook_guid
        if end_time is None:
            note_filter.words = "created:" + start_time + "Z"
        else:
            note_filter.words = "created:" + start_time + "Z -" + end_time

        return note_filter
Example #16
0
 def _process_notes(self, notebook_guid):
     """process notes in given notebook checking if any need to be synced to backup location"""
     note_filter = NoteFilter()
     note_filter.notebookGuid = notebook_guid
     result_spec = NotesMetadataResultSpec()
     # evernote api will return None for almost all fields unless set them on in metadata
     result_spec.includeTitle = True
     result_spec.includeUpdated = True
     offset = 0
     notes = self.note_store.findNotesMetadata(self.token, note_filter, offset, 250, result_spec)
     while offset < notes.totalNotes:
         for en in notes.notes:
             # only fetch actual note if has been updated since last time
             if en.guid not in self.tracking or en.updated != self.tracking[en.guid]:
                 note = self._create_note(en.guid)
                 self._save(note)
         offset += 250
         notes = self.note_store.findNotesMetadata(self.token, note_filter, offset, 250, result_spec)
     print 'synced %i notes to %s' % (self.cnt, self.local_dir)
     self.logger.info('synced %i notes to %s' % (self.cnt, self.local_dir))
def default_notbook():
    authToken = session['identifier']
    noteStore = get_notestore()
    notebooks = noteStore.listNotebooks(authToken)

    for notebook in notebooks:
        defaultNotebook = notebook
        break

    nfilter = NoteFilter()
    nfilter.notebookGuid = defaultNotebook.guid
    result_spec = NotesMetadataResultSpec(includeTitle=True)
    notes = noteStore.findNotesMetadata(authToken, nfilter, 0, 100, result_spec)
    print notes
    for note in notes.notes:
     	if note.guid == "e00c1b8b-cc4f-48b5-bdbb-5f6069dbbc4a":
      		fullnote = noteStore.getNote(authToken,note.guid,True,True,True,True)
      		resources = fullnote.resources

    syncState = noteStore.getSyncState(authToken)
    mergeByTimeStamp()
    return resources[0].guid
Example #18
0
    def get_note_filter(self, start_time, notebook_name, end_time=None):

        for notebook in self.get_note_store().listNotebooks():
            if notebook.name == notebook_name:
                event_notebook_guid = notebook.guid
                break

        if event_notebook_guid is None:
            raise EvernoteConnectorException(
                "Unable to find a notebook with the name '" + notebook_name +
                "'")

        note_filter = NoteFilter()
        note_filter.order = NoteSortOrder.CREATED
        note_filter.ascending = True
        note_filter.notebookGuid = event_notebook_guid
        if end_time is None:
            note_filter.words = "created:" + start_time + "Z"
        else:
            note_filter.words = "created:" + start_time + "Z -" + end_time

        return note_filter
Example #19
0
def main(argv):
  print 'starting the python process'
  # the list of already entered images
  guidList = []
  # Evernote login credentials
  dev_token = "S=s1:U=8fb0e:E=150ba27eb99:C=1496276bc48:P=1cd:A=en-devtoken:V=2:H=cb6610893ef12aa4b914d15d19befa09"
  client = EvernoteClient(token=dev_token, sandbox=True)
  NoteStore = client.get_note_store()
  filterNote = NoteFilter(order=NoteSortOrder.UPDATED)
  filterNote.notebookGuid = 'cdbc8617-c551-4148-b659-7ccb5d47859e'
  searchResults = NoteStore.findNotes(filterNote, 0, 20)
  
  for note in searchResults.notes:
    if note.resources != None:
      for r in note.resources:
        # save each livescribe file and add the guid to the list
        try:
          guidList.append(save_files(NoteStore, r.guid))
        except:
          print 'Unexpected error when saving original files:', sys.exc_info()[0]
          raise
  # now you start the evernote listening thread
  while(True):
    newNote = NoteStore.findNotes(filterNote, 0, 1)
    for note in newNote.notes:
      if note.resources != None:
        try:
          for r in note.resources:
            if not (r.guid in guidList):
              guidList.append(save_files(NoteStore, r.guid))
              print 'found new image:', r.guid, 'going to sleep for 10 seconds'
              time.sleep(10)
            else:
              print 'no new images - going to sleep for 20 seconds'
              time.sleep(20)
        except:
          print 'Unexpected error when looping:', sys.exc_info()[0]
          raise
Example #20
0
def get_ev_notes():
  dev_token = app.config['EN_DEV_TOKEN']
  notestore_url = app.config['EN_NOTESTORE_URL']
  nb_guid = app.config['EN_NB_GUID']
 
  client = EvernoteClient(token=dev_token)
  note_store = client.get_note_store()

  filt = NoteFilter()
  filt.notebookGuid = nb_guid

  spec = NotesMetadataResultSpec()
  spec.includeTitle = True

  notemetalist = note_store.findNotesMetadata(dev_token, filt, 0, 100, spec)
  notes = []
  for note_data in notemetalist.notes:
    note = note_store.getNote(dev_token, note_data.guid, True, True, True, True)

    title = note.title
    author = note.attributes.author
    date = note.updated
    url = note.attributes.sourceURL    
    cont = note.content
    note_tags = []

    tag_guids = note.tagGuids
    if tag_guids is not None:
      for tag_guid in tag_guids:
        tag = note_store.getTag(dev_token, tag_guid)
        note_tags.append({'guid': tag_guid, 'name': tag.name})

    notes.append({'guid': note_data.guid, 'title': title, 'date_modified': date, 'author': author, 'content': cont, 'tags': note_tags})
  
  #print notes
  return dumps(notes)
Example #21
0
def hello():
    global latestNote
    global updated
    global created

    auth_token = "S=s1:U=6eb51:E=146ce55b0ee:C=13f76a484f1:P=1cd:A=en-devtoken:V=2:H=5d05df82a62652c0ed8f2e544df37758"

    if auth_token == "":
        print "Please fill in your developer token"
        print "To get a developer token, visit " \
                "https://sandbox.evernote.com/api/DeveloperToken.action"
        exit(1)

    client = EvernoteClient(token=auth_token, sandbox=True)
    user_store = client.get_user_store()

    version_ok = user_store.checkVersion(
            "Evernote EDAMTest (Python)",
            UserStoreConstants.EDAM_VERSION_MAJOR,
            UserStoreConstants.EDAM_VERSION_MINOR
            )
    #print "Is my Evernote API version up to date? ", str(version_ok)
    #print ""
    if not version_ok:
        exit(1)

    note_store = client.get_note_store()

    # List all of the notebooks in the user's account
    notebooks = note_store.listNotebooks()
    nb = None
    #print "Found ", len(notebooks), " notebooks:"
    for notebook in notebooks:
        #print "  * ", notebook.name
        if notebook.name == "Note":
            nb = notebook;
            break

    if not nb:
        print "Note book is not found in your account"
        exit(1)

    filter = NoteFilter()
    filter.notebookGuid = nb.guid
    filter.order = Types.NoteSortOrder.UPDATED

    spec = NotesMetadataResultSpec()
    spec.includeTitle = True

    noteML = note_store.findNotesMetadata(auth_token, filter, 0, 1, spec)
    content = ""
    content_org = ""
    content_new = ""

    for note in noteML.notes:
        noteID = note.guid

        if note.created == created and note.updated == updated:
            content = latestNote
        else:
            content = note_store.getNoteContent(auth_token, noteID);
            latestNote = content
            created = note.created
            updated = note.updated

        m = re.search(r'<en-note><div>(?P<content>.+)</div></en-note>', content)
        if m:
            content_org = "%s\n" % m.group('content')
            content = re.sub('<[^>]*>', '', content_org)
            line = '''<tspan x="%d" y="%d">%s</tspan>'''

            n = 57
            m = 0
            index = n
            y_aix = 450
            length = len(content)

            while index <= length:
                while ord(content[index-1]) < 128 and content[index-1] != ' ' and index != length:
                    index = index - 1
                index = ( m+n if index == m else index)
                content_new += line%(300, y_aix, content[m:index])

                if index == length:
                    break
                y_aix = y_aix + 30
                m = index
                index = index + n
                if index > length:
                    index = length

        content_new = content_new.decode('utf-8')
        content_org = content_org.decode('utf-8')

    #output = weather.getAndDraw()
    output = getWeather.w2svg("forecast")

    #output = codecs.open('weather-script-output.svg', 'r', encoding='utf-8').read()
    output = output.replace('NOTE_TEXT', content_new)
    output = output.replace('NOTE_ORG', content_org)

    ## Write output
    #codecs.open('weather.svg', 'w', encoding='utf-8').write(output)

    return output
 def getNotes(self):
     noteFilter = NoteFilter()
     noteFilter.notebookGuid = self.__dict__["notebook"].guid
     noteList = self.noteStore.findNotes(self.__dict__["authToken"], noteFilter, 0, int(MAX_NOTES))
     return [Note(note, self.__dict__["noteStore"], self.__dict__["authToken"]) for note in noteList.notes]
Example #23
0
from evernote.api.client import EvernoteClient
from evernote.edam.notestore.ttypes import NoteFilter, NotesMetadataResultSpec
from evernote.edam.type.ttypes import NoteSortOrder

dev_token = "S=s1:U=8fb0e:E=150ba27eb99:C=1496276bc48:P=1cd:A=en-devtoken:V=2:H=cb6610893ef12aa4b914d15d19befa09"
client = EvernoteClient(token=dev_token, sandbox=True)

NoteStore = client.get_note_store()


filterNote = NoteFilter(order=NoteSortOrder.UPDATED)
filterNote.notebookGuid = 'cdbc8617-c551-4148-b659-7ccb5d47859e'

searchResults = NoteStore.findNotes(filterNote, 0, 10)

def getImage(count, rerun):
  for note in searchResults.notes:
    if note.resources != None:
      for r in note.resources:
        guid = r.guid
        print guid
        try:
          resource = NoteStore.getResource(guid, True, False, True, False)
          # get the file content so you can save it
          file_content = resource.data.body
          #print file_content
          file_name = resource.attributes.fileName

          # save the file into the output folder
          file_save = open('../Calvin/output/' + file_name, "wb")
          file_save.write(file_content)
Example #24
0
    def process_goal_updates(self, stored_goal_states):
        note_filter = NoteFilter()

        # Get all the goals
        for notebook in self.get_note_store().listNotebooks():

            if notebook.name not in [
                    "Backlog", "Current", "Complete", "Dropped"
            ]:
                continue

            note_filter.notebookGuid = notebook.guid

            note_metadata_list = self.get_all_notes_metadata(
                self.auth_token, note_filter,
                NoteStore.NotesMetadataResultSpec())

            # For each goal
            for note_metadata in note_metadata_list:

                # Check if the goal is new or has changed state (moved from another notebook)
                if note_metadata.guid in stored_goal_states[notebook.name]:
                    # the goal is in the same state as it was the last time we checked
                    continue
                else:
                    # the goal is new, or it has changed state
                    # search to see if it was previously in a different notebook
                    other_notebooks = [
                        "Backlog", "Current", "Complete", "Dropped"
                    ]
                    other_notebooks.remove(notebook.name)

                    goal_has_moved = None

                    for previous_notebook in other_notebooks:
                        if note_metadata.guid in stored_goal_states[
                                previous_notebook]:
                            # We know the note used to be in this notebook, so annotate the note and update what we know

                            annotation = (datetime.now()-timedelta(days=1)).strftime("%Y-%m-%d") \
                                                        + " Moved from " + previous_notebook \
                                                        + " to " + notebook.name
                            self.annotate_note(note_metadata.guid, annotation,
                                               False)

                            stored_goal_states[previous_notebook].remove(
                                note_metadata.guid)
                            stored_goal_states[notebook.name].append(
                                note_metadata.guid)

                            goal_has_moved = True
                            break

                    if goal_has_moved is None:
                        # The note has been newly added
                        # So annotate the note and save the state of the note locally

                        annotation = (datetime.now()-timedelta(days=1)).strftime("%Y-%m-%d") \
                                                        + " Added to " + notebook.name
                        self.annotate_note(note_metadata.guid, annotation,
                                           True)

                        stored_goal_states[notebook.name].append(
                            note_metadata.guid)

        return stored_goal_states