Пример #1
0
 def addDBNote(self, dbNote):
     """:type dbNote: sqlite.Row"""
     enNote = EvernoteNotePrototype(db_note=dbNote)
     if not enNote:
         log(dbNote)
         log(dbNote.keys)
         log(dir(dbNote))
     assert enNote
     self.addNote(enNote)
Пример #2
0
 def getNoteRemote(self):
     if self.api_calls > EVERNOTE.IMPORT.API_CALLS_LIMIT > -1:
         log(
             "Aborting Evernote.getNoteRemote: EVERNOTE.IMPORT.API_CALLS_LIMIT of %d has been reached" % EVERNOTE.IMPORT.API_CALLS_LIMIT)
         return None
     if not self.getNoteRemoteAPICall():
         return False
     # self.tagGuids, self.tagNames = self.evernote.get_tag_names_from_guids(self.whole_note.tagGuids)
     self.setNoteTags(tag_guids=self.whole_note.tagGuids)
     self.addNoteFromServerToDB()
     if not self.keepEvernoteTags:
         self.tagNames = []
     self.reportSuccess(EvernoteNotePrototype(whole_note=self.whole_note, tags=self.tagNames))
     return True
Пример #3
0
 def getNoteLocal(self):
     # Check Anknotes database for note
     query = "guid = '%s'" % self.guid
     if self.UpdateSequenceNum > -1:
         query += " AND `updateSequenceNum` = %d" % self.UpdateSequenceNum
     db_note = ankDB().first(query)
     """:type : sqlite.Row"""
     if not db_note:
         return False
     if not self.use_local_db_only:
         log(' ' + '-' * 14 + ' ' * 5 + "> getNoteLocal: %s" % db_note['title'], 'api')
     assert db_note['guid'] == self.guid
     self.reportSuccess(EvernoteNotePrototype(db_note=db_note), 1)
     self.setNoteTags(tag_names=self.result.Note.TagNames, tag_guids=self.result.Note.TagGuids)
     return True
Пример #4
0
    def __init__(self, title=None, note=None, number=1):
        """
        :type title: EvernoteNoteTitle
        :type note: EvernoteNotePrototype.EvernoteNotePrototype
        """
        assert note or title
        self.Outline = None
        if note:
            if (isinstance(note, sqlite.Row)):
                note = EvernoteNotePrototype(db_note=note)

            self.Note = note
            self.Title = EvernoteNoteTitle(note)
        else:
            self.Title = EvernoteNoteTitle(title)
            self.Note = None
        self.Number = number
        self.Children = []
        self.__isSorted = False
Пример #5
0
def main(evernote=None, anki=None):
    # @clockit
    def print_results(log_folder='Diff\\SeeAlso', full=False, final=False):
        if final:
            oldResults = n.old.content.final
            newResults = n.new.content.final
        elif full:
            oldResults = n.old.content.updated
            newResults = n.new.content.updated
        else:
            oldResults = n.old.see_also.updated
            newResults = n.new.see_also.updated
        diff = generate_diff(oldResults, newResults)
        if not 6 in FILES.LOGS.SEE_ALSO_DISABLED:
            log.plain(diff, log_folder + '\\Diff\\%s\\' % n.match_type + enNote.FullTitle, extension='htm', clear=True)
            log.plain(diffify(oldResults, split=False), log_folder + '\\Original\\%s\\' % n.match_type + enNote.FullTitle,
                      extension='htm', clear=True)
            log.plain(diffify(newResults, split=False), log_folder + '\\New\\%s\\' % n.match_type + enNote.FullTitle,
                      extension='htm', clear=True)
            if final:
                log.plain(oldResults, log_folder + '\\Final\\Old\\%s\\' % n.match_type + enNote.FullTitle, extension='htm',
                          clear=True)
                log.plain(newResults, log_folder + '\\Final\\New\\%s\\' % n.match_type + enNote.FullTitle, extension='htm',
                          clear=True)
        log.plain(diff + '\n', log_folder + '\\__All')

    # @clockit
    def process_note():
        n.old.content = notes.version.pstrings(enNote.Content)
        if not n.old.content.regex_original.successful_match:
            if n.new.see_also.original == "":
                n.new.content = notes.version.pstrings(n.old.content.original)
                return False
            n.new.content = notes.version.pstrings(n.old.content.original.replace('</en-note>',
                                                                                  '<div><span><br/></span></div>' + n.new.see_also.original + '\n</en-note>'))
            n.new.see_also.updated = str_process(n.new.content.original)
            n.old.see_also.updated = str_process(n.old.content.original)
            log.plain(enNote.Guid + '<BR>' + ', '.join(
                enNote.TagNames) + '<HR>' + enNote.Content + '<HR>' + n.new.see_also.updated,
                      'SeeAlsoMatchFail\\' + enNote.FullTitle, extension='htm', clear=True)
            n.match_type = 'V1'
        else:
            n.old.see_also = notes.version.pstrings(n.old.content.regex_original.main)
            n.match_type = 'V2'
            if n.old.see_also.regex_processed.successful_match:
                assert True or str_process(n.old.content.regex_original.main) is n.old.content.regex_processed.main
                n.old.content.updated = n.old.content.original.replace(n.old.content.regex_original.main,
                                                                       str_process(n.old.content.regex_original.main))
                n.old.see_also.useProcessed()
                n.match_type += 'V3'
            n.new.see_also.regex_original.subject = n.new.see_also.original + '</en-note>'
            if not n.new.see_also.regex_original.successful_match:
                log.plain(enNote.Guid + '\n' + ', '.join(enNote.TagNames) + '\n' + n.new.see_also.original,
                          'SeeAlsoNewMatchFail\\' + enNote.FullTitle, extension='htm', clear=True)
                # see_also_replace_old = n.old.content.original.match.processed.see_also.processed.content
                n.old.see_also.updated = n.old.content.regex_updated.see_also
                n.new.see_also.updated = n.new.see_also.processed
                n.match_type += 'V4'
            else:
                assert (n.old.content.regex_processed.see_also_content == notes.version.see_also_match(
                    str_process(n.old.content.regex_original.main)).see_also_content)
                n.old.see_also.updated = notes.version.see_also_match(
                    str_process(n.old.content.regex_original.main)).see_also_content
                n.new.see_also.updated = str_process(n.new.see_also.regex_original.see_also_content)
                n.match_type += 'V5'
            n.new.content.updated = n.old.content.updated.replace(n.old.see_also.updated, n.new.see_also.updated)

    def print_results_fail(title, status=None):
        log.go(title + ' for %s' % enNote.FullTitle, 'NoUpdate')
        print_results('NoMatch\\SeeAlso')
        print_results('NoMatch\\Contents', full=True)
        if status is None:
            status = EvernoteAPIStatus.GenericError
        tmr.reportStatus(status)

    noteType = 'SeeAlso-Step6'
    db = ankDB()
    db.delete("noteType = '%s'" % noteType, table=TABLES.NOTE_VALIDATION_QUEUE)
    results = db.all("SELECT DISTINCT s.target_evernote_guid, n.* FROM {s} as s, {n} as n  "
                     "WHERE s.target_evernote_guid = n.guid AND n.tagNames NOT LIKE '{t_toc}' "
                     "AND n.tagNames NOT LIKE '{t_out}' ORDER BY n.title ASC;")
    # count_queued = 0
    log = Logger('See Also\\6-update_see_also_footer_in_evernote_notes\\', rm_path=True)
    tmr = stopwatch.Timer(len(results), 25, infoStr='Updating Evernote See Also Notes',
                          label=log.base_path, do_print=True)
    # log.banner("UPDATING EVERNOTE SEE ALSO CONTENT: %d NOTES" % len(results), do_print=True)
    notes_updated = []
    # number_updated = 0
    for result in results:
        enNote = EvernoteNotePrototype(db_note=result)
        n = notes()
        tmr.step(enNote.FullTitle if enNote.Status.IsSuccess else '(%s)' % enNote.Guid)
        flds = get_anki_fields_from_evernote_guids(enNote.Guid)
        if not flds:
            print_results_fail('No Anki Note Found')
            continue
        flds = flds.split("\x1f")
        n.new.see_also = notes.version.pstrings(flds[FIELDS.ORD.SEE_ALSO])
        result = process_note()
        if result is False:
            print_results_fail('No Match')
            continue
        if n.match_type != 'V1' and str_process(n.old.see_also.updated) == n.new.see_also.updated:
            print_results_fail('Match but contents are the same', EvernoteAPIStatus.RequestSkipped)
            continue
        print_results()
        print_results('Diff\\Contents', final=True)
        enNote.Content = n.new.content.final
        if not EVERNOTE.UPLOAD.ENABLED:
            tmr.reportStatus(EvernoteAPIStatus.Disabled)
            continue
        if not evernote:
            evernote = Evernote()
        whole_note = tmr.autoStep(evernote.makeNote(enNote=enNote, noteType=noteType), update=True)
        if tmr.report_result is False:
            raise ValueError
        if tmr.status.IsDelayableError:
            break
        if tmr.status.IsSuccess:
            notes_updated.append(EvernoteNotePrototype(whole_note=whole_note))
    if tmr.is_success and not anki:
        anki = Anki()
    tmr.Report(0, anki.update_evernote_notes(notes_updated) if tmr.is_success else 0)
Пример #6
0
 def processNote(self, enNote):
     """:type enNote: EvernoteNote.EvernoteNote"""
     db = ankDB()
     if self.processingFlags.populateRootTitlesList or self.processingFlags.populateRootTitlesDict or self.processingFlags.populateMissingRootTitlesList or self.processingFlags.populateMissingRootTitlesDict:
         if enNote.IsChild:
             # log([enNote.Title, enNote.Level, enNote.Title.TitleParts, enNote.IsChild])
             rootTitle = enNote.Title.Root
             rootTitleStr = generateTOCTitle(rootTitle)
             if self.processingFlags.populateMissingRootTitlesList or self.processingFlags.populateMissingRootTitlesDict:
                 if not rootTitleStr in self.RootNotesExisting.TitlesList:
                     if not rootTitleStr in self.RootNotesMissing.TitlesList:
                         self.RootNotesMissing.TitlesList.append(
                             rootTitleStr)
                         self.RootNotesMissing.ChildTitlesDict[
                             rootTitleStr] = {}
                         self.RootNotesMissing.ChildNotesDict[
                             rootTitleStr] = {}
                     if not enNote.Title.Base:
                         log(enNote.Title)
                         log(enNote.Base)
                     assert enNote.Title.Base
                     childBaseTitleStr = enNote.Title.Base.FullTitle
                     if childBaseTitleStr in self.RootNotesMissing.ChildTitlesDict[
                             rootTitleStr]:
                         log_error(
                             "Duplicate Child Base Title String. \n%-18s%s\n%-18s%s: %s\n%-18s%s"
                             % ('Root Note Title: ', rootTitleStr,
                                'Child Note: ', enNote.Guid,
                                childBaseTitleStr, 'Duplicate Note: ',
                                self.RootNotesMissing.ChildTitlesDict[
                                    rootTitleStr][childBaseTitleStr]),
                             crosspost_to_default=False)
                         if not hasattr(self,
                                        'loggedDuplicateChildNotesWarning'):
                             log("     > WARNING: Duplicate Child Notes found when processing Root Notes. See error log for more details"
                                 )
                             self.loggedDuplicateChildNotesWarning = True
                     self.RootNotesMissing.ChildTitlesDict[rootTitleStr][
                         childBaseTitleStr] = enNote.Guid
                     self.RootNotesMissing.ChildNotesDict[rootTitleStr][
                         enNote.Guid] = enNote
             if self.processingFlags.populateRootTitlesList or self.processingFlags.populateRootTitlesDict:
                 if not rootTitleStr in self.RootNotes.TitlesList:
                     self.RootNotes.TitlesList.append(rootTitleStr)
                     if self.processingFlags.populateRootTitlesDict:
                         self.RootNotes.TitlesDict[rootTitleStr][
                             enNote.Guid] = enNote.Title.Base
                         self.RootNotes.NotesDict[rootTitleStr][
                             enNote.Guid] = enNote
     if self.processingFlags.populateChildRootTitles or self.processingFlags.populateExistingRootTitlesList or self.processingFlags.populateExistingRootTitlesDict:
         if enNote.IsRoot:
             rootTitle = enNote.Title
             rootTitleStr = generateTOCTitle(rootTitle)
             rootGuid = enNote.Guid
             if self.processingFlags.populateExistingRootTitlesList or self.processingFlags.populateExistingRootTitlesDict or self.processingFlags.populateMissingRootTitlesList:
                 if not rootTitleStr in self.RootNotesExisting.TitlesList:
                     self.RootNotesExisting.TitlesList.append(rootTitleStr)
             if self.processingFlags.populateChildRootTitles:
                 childNotes = db.execute(
                     "title LIKE ? || ':%' ORDER BY title ASC",
                     rootTitleStr)
                 child_count = 0
                 for childDbNote in childNotes:
                     child_count += 1
                     childGuid = childDbNote['guid']
                     childEnNote = EvernoteNotePrototype(
                         db_note=childDbNote)
                     if child_count is 1:
                         self.RootNotesChildren.TitlesDict[rootGuid] = {}
                         self.RootNotesChildren.NotesDict[rootGuid] = {}
                     childBaseTitle = childEnNote.Title.Base
                     self.RootNotesChildren.TitlesDict[rootGuid][
                         childGuid] = childBaseTitle
                     self.RootNotesChildren.NotesDict[rootGuid][
                         childGuid] = childEnNote
Пример #7
0
 def getEnNoteFromDBByGuid(self, guid):
     return EvernoteNotePrototype(db_note=self.getNoteFromDBByGuid(guid))
Пример #8
0
 def upload_validated_notes(self, automated=False):
     db = ankDB(TABLES.NOTE_VALIDATION_QUEUE)
     dbRows = db.all("validation_status = 1")
     notes_created, notes_updated, queries1, queries2 = ([]
                                                         for i in range(4))
     """
     :type: (list[EvernoteNote], list[EvernoteNote], list[str], list[str])
     """
     noteFetcher = EvernoteNoteFetcher()
     tmr = stopwatch.Timer(len(dbRows),
                           25,
                           infoStr="Upload of Validated Evernote Notes",
                           automated=automated,
                           enabled=EVERNOTE.UPLOAD.ENABLED,
                           max_allowed=EVERNOTE.UPLOAD.MAX,
                           label='Validation\\upload_validated_notes\\',
                           display_initial_info=True)
     if tmr.actionInitializationFailed:
         return tmr.status, 0, 0
     for dbRow in dbRows:
         entry = EvernoteValidationEntry(dbRow)
         evernote_guid, rootTitle, contents, tagNames, notebookGuid, noteType = entry.items(
         )
         tagNames = tagNames.split(',')
         if not tmr.checkLimits():
             break
         whole_note = tmr.autoStep(
             self.evernote.makeNote(rootTitle,
                                    contents,
                                    tagNames,
                                    notebookGuid,
                                    guid=evernote_guid,
                                    noteType=noteType,
                                    validated=True), rootTitle,
             evernote_guid)
         if tmr.report_result is False:
             raise ValueError
         if tmr.status.IsDelayableError:
             break
         if not tmr.status.IsSuccess:
             continue
         if not whole_note.tagNames:
             whole_note.tagNames = tagNames
         noteFetcher.addNoteFromServerToDB(whole_note, tagNames)
         note = EvernoteNotePrototype(whole_note=whole_note)
         assert whole_note.tagNames
         assert note.Tags
         if evernote_guid:
             notes_updated.append(note)
             queries1.append([evernote_guid])
         else:
             notes_created.append(note)
             queries2.append([rootTitle, contents])
     else:
         tmr.reportNoBreak()
     tmr.Report(
         self.anki.add_evernote_notes(notes_created)
         if tmr.counts.created else 0,
         self.anki.update_evernote_notes(notes_updated)
         if tmr.counts.updated else 0)
     if tmr.counts.created.completed.subcount:
         db.executemany("DELETE FROM {t} WHERE title = ? and contents = ? ",
                        queries2)
     if tmr.counts.updated.completed.subcount:
         db.executemany("DELETE FROM {t} WHERE guid = ? ", queries1)
     if tmr.is_success:
         db.commit()
     if tmr.should_retry:
         create_timer(
             30 if tmr.status.IsDelayableError else
             EVERNOTE.UPLOAD.RESTART_INTERVAL, self.upload_validated_notes,
             True)
     return tmr.status, tmr.count, 0
Пример #9
0
    def create_toc_auto(self):
        db = ankDB()

        def check_old_values():
            old_values = db.first(
                "UPPER(title) = UPPER(?) AND tagNames LIKE '{t_tauto}'",
                rootTitle,
                columns='guid, content')
            if not old_values:
                log.go(rootTitle, 'Add')
                return None, contents
            evernote_guid, old_content = old_values
            noteBodyUnencoded = self.evernote.makeNoteBody(contents,
                                                           encode=False)
            if type(old_content) != type(noteBodyUnencoded):
                log.go([rootTitle,
                        type(old_content),
                        type(noteBodyUnencoded)], 'Update\\Diffs\\_')
                raise UnicodeWarning
            old_content = old_content.replace('guid-pending',
                                              evernote_guid).replace("'", '"')
            noteBodyUnencoded = noteBodyUnencoded.replace(
                'guid-pending', evernote_guid).replace("'", '"')
            if old_content == noteBodyUnencoded:
                log.go(rootTitle, 'Skipped')
                tmr.reportSkipped()
                return None, None
            log.go(noteBodyUnencoded, 'Update\\New\\' + rootTitle, clear=True)
            log.go(generate_diff(old_content, noteBodyUnencoded),
                   'Update\\Diffs\\' + rootTitle,
                   clear=True)
            return evernote_guid, contents.replace(
                '/guid-pending/',
                '/%s/' % evernote_guid).replace('/guid-pending/',
                                                '/%s/' % evernote_guid)

        update_regex()
        noteType = 'create-toc_auto_notes'
        db.delete("noteType = '%s'" % noteType,
                  table=TABLES.NOTE_VALIDATION_QUEUE)
        NotesDB = EvernoteNotes()
        NotesDB.baseQuery = ANKNOTES.HIERARCHY.ROOT_TITLES_BASE_QUERY
        dbRows = NotesDB.populateAllNonCustomRootNotes()
        notes_created, notes_updated = [], []
        """
        :type: (list[EvernoteNote], list[EvernoteNote])
        """
        info = stopwatch.ActionInfo('Creation of Table of Content Note(s)',
                                    row_source='Root Title(s)')
        log = Logger('See Also\\2-%s\\' % noteType, rm_path=True)
        tmr = stopwatch.Timer(len(dbRows),
                              25,
                              info,
                              max_allowed=EVERNOTE.UPLOAD.MAX,
                              label=log.base_path)
        if tmr.actionInitializationFailed:
            return tmr.status, 0, 0
        for dbRow in dbRows:
            rootTitle, contents, tagNames, notebookGuid = dbRow.items()
            tagNames = (set(tagNames[1:-1].split(','))
                        | {TAGS.TOC, TAGS.TOC_AUTO} |
                        ({"#Sandbox"} if EVERNOTE.API.IS_SANDBOXED else set())
                        ) - {TAGS.REVERSIBLE, TAGS.REVERSE_ONLY}
            rootTitle = generateTOCTitle(rootTitle)
            evernote_guid, contents = check_old_values()
            if contents is None:
                continue
            if not tmr.checkLimits():
                break
            if not EVERNOTE.UPLOAD.ENABLED:
                tmr.reportStatus(EvernoteAPIStatus.Disabled, title=rootTitle)
                continue
            whole_note = tmr.autoStep(
                self.evernote.makeNote(rootTitle,
                                       contents,
                                       tagNames,
                                       notebookGuid,
                                       noteType=noteType,
                                       guid=evernote_guid), rootTitle,
                evernote_guid)
            if tmr.report_result is False:
                raise ValueError
            if tmr.status.IsDelayableError:
                break
            if not tmr.status.IsSuccess:
                continue
            (notes_updated if evernote_guid else notes_created).append(
                EvernoteNotePrototype(whole_note=whole_note))
        tmr.Report(
            self.anki.add_evernote_notes(notes_created)
            if tmr.counts.created.completed else 0,
            self.anki.update_evernote_notes(notes_updated)
            if tmr.counts.updated.completed else 0)
        if tmr.counts.queued:
            db.commit()
        return tmr.status, tmr.count, tmr.counts.skipped.val
Пример #10
0
def main(evernote=None, anki=None):
    # @clockit
    def print_results(log_folder='Diff\\SeeAlso', full=False, final=False):
        if final:
            oldResults = n.old.content.final
            newResults = n.new.content.final
        elif full:
            oldResults = n.old.content.updated
            newResults = n.new.content.updated
        else:
            oldResults = n.old.see_also.updated
            newResults = n.new.see_also.updated
        diff = generate_diff(oldResults, newResults)
        if not 6 in FILES.LOGS.SEE_ALSO_DISABLED:
            log.plain(diff,
                      log_folder + '\\Diff\\%s\\' % n.match_type +
                      enNote.FullTitle,
                      extension='htm',
                      clear=True)
            log.plain(diffify(oldResults, split=False),
                      log_folder + '\\Original\\%s\\' % n.match_type +
                      enNote.FullTitle,
                      extension='htm',
                      clear=True)
            log.plain(diffify(newResults, split=False),
                      log_folder + '\\New\\%s\\' % n.match_type +
                      enNote.FullTitle,
                      extension='htm',
                      clear=True)
            if final:
                log.plain(oldResults,
                          log_folder + '\\Final\\Old\\%s\\' % n.match_type +
                          enNote.FullTitle,
                          extension='htm',
                          clear=True)
                log.plain(newResults,
                          log_folder + '\\Final\\New\\%s\\' % n.match_type +
                          enNote.FullTitle,
                          extension='htm',
                          clear=True)
        log.plain(diff + '\n', log_folder + '\\__All')

    # @clockit
    def process_note():
        n.old.content = notes.version.pstrings(enNote.Content)
        if not n.old.content.regex_original.successful_match:
            if n.new.see_also.original == "":
                n.new.content = notes.version.pstrings(n.old.content.original)
                return False
            n.new.content = notes.version.pstrings(
                n.old.content.original.replace(
                    '</en-note>', '<div><span><br/></span></div>' +
                    n.new.see_also.original + '\n</en-note>'))
            n.new.see_also.updated = str_process(n.new.content.original)
            n.old.see_also.updated = str_process(n.old.content.original)
            log.plain(enNote.Guid + '<BR>' + ', '.join(enNote.TagNames) +
                      '<HR>' + enNote.Content + '<HR>' +
                      n.new.see_also.updated,
                      'SeeAlsoMatchFail\\' + enNote.FullTitle,
                      extension='htm',
                      clear=True)
            n.match_type = 'V1'
        else:
            n.old.see_also = notes.version.pstrings(
                n.old.content.regex_original.main)
            n.match_type = 'V2'
            if n.old.see_also.regex_processed.successful_match:
                assert True or str_process(
                    n.old.content.regex_original.main
                ) is n.old.content.regex_processed.main
                n.old.content.updated = n.old.content.original.replace(
                    n.old.content.regex_original.main,
                    str_process(n.old.content.regex_original.main))
                n.old.see_also.useProcessed()
                n.match_type += 'V3'
            n.new.see_also.regex_original.subject = n.new.see_also.original + '</en-note>'
            if not n.new.see_also.regex_original.successful_match:
                log.plain(enNote.Guid + '\n' + ', '.join(enNote.TagNames) +
                          '\n' + n.new.see_also.original,
                          'SeeAlsoNewMatchFail\\' + enNote.FullTitle,
                          extension='htm',
                          clear=True)
                # see_also_replace_old = n.old.content.original.match.processed.see_also.processed.content
                n.old.see_also.updated = n.old.content.regex_updated.see_also
                n.new.see_also.updated = n.new.see_also.processed
                n.match_type += 'V4'
            else:
                assert (n.old.content.regex_processed.see_also_content ==
                        notes.version.see_also_match(
                            str_process(n.old.content.regex_original.main)
                        ).see_also_content)
                n.old.see_also.updated = notes.version.see_also_match(
                    str_process(
                        n.old.content.regex_original.main)).see_also_content
                n.new.see_also.updated = str_process(
                    n.new.see_also.regex_original.see_also_content)
                n.match_type += 'V5'
            n.new.content.updated = n.old.content.updated.replace(
                n.old.see_also.updated, n.new.see_also.updated)

    def print_results_fail(title, status=None):
        log.go(title + ' for %s' % enNote.FullTitle, 'NoUpdate')
        print_results('NoMatch\\SeeAlso')
        print_results('NoMatch\\Contents', full=True)
        if status is None:
            status = EvernoteAPIStatus.GenericError
        tmr.reportStatus(status)

    noteType = 'SeeAlso-Step6'
    db = ankDB()
    db.delete("noteType = '%s'" % noteType, table=TABLES.NOTE_VALIDATION_QUEUE)
    results = db.all(
        "SELECT DISTINCT s.target_evernote_guid, n.* FROM {s} as s, {n} as n  "
        "WHERE s.target_evernote_guid = n.guid AND n.tagNames NOT LIKE '{t_toc}' "
        "AND n.tagNames NOT LIKE '{t_out}' ORDER BY n.title ASC;")
    # count_queued = 0
    log = Logger('See Also\\6-update_see_also_footer_in_evernote_notes\\',
                 rm_path=True)
    tmr = stopwatch.Timer(len(results),
                          25,
                          infoStr='Updating Evernote See Also Notes',
                          label=log.base_path,
                          do_print=True)
    # log.banner("UPDATING EVERNOTE SEE ALSO CONTENT: %d NOTES" % len(results), do_print=True)
    notes_updated = []
    # number_updated = 0
    for result in results:
        enNote = EvernoteNotePrototype(db_note=result)
        n = notes()
        tmr.step(enNote.FullTitle if enNote.Status.IsSuccess else '(%s)' %
                 enNote.Guid)
        flds = get_anki_fields_from_evernote_guids(enNote.Guid)
        if not flds:
            print_results_fail('No Anki Note Found')
            continue
        flds = flds.split("\x1f")
        n.new.see_also = notes.version.pstrings(flds[FIELDS.ORD.SEE_ALSO])
        result = process_note()
        if result is False:
            print_results_fail('No Match')
            continue
        if n.match_type != 'V1' and str_process(
                n.old.see_also.updated) == n.new.see_also.updated:
            print_results_fail('Match but contents are the same',
                               EvernoteAPIStatus.RequestSkipped)
            continue
        print_results()
        print_results('Diff\\Contents', final=True)
        enNote.Content = n.new.content.final
        if not EVERNOTE.UPLOAD.ENABLED:
            tmr.reportStatus(EvernoteAPIStatus.Disabled)
            continue
        if not evernote:
            evernote = Evernote()
        whole_note = tmr.autoStep(evernote.makeNote(enNote=enNote,
                                                    noteType=noteType),
                                  update=True)
        if tmr.report_result is False:
            raise ValueError
        if tmr.status.IsDelayableError:
            break
        if tmr.status.IsSuccess:
            notes_updated.append(EvernoteNotePrototype(whole_note=whole_note))
    if tmr.is_success and not anki:
        anki = Anki()
    tmr.Report(
        0,
        anki.update_evernote_notes(notes_updated) if tmr.is_success else 0)