Ejemplo n.º 1
0
    def findNotes(self, keywords, count, createOrder=False, offset=0):
        """ WORK WITH NOTES """
        noteFilter = NoteStore.NoteFilter(order=Types.NoteSortOrder.RELEVANCE)
        noteFilter.order = getattr(Types.NoteSortOrder, self.noteSortOrder)
        if createOrder:
            noteFilter.order = Types.NoteSortOrder.CREATED

        if keywords:
            noteFilter.words = keywords

        meta = NotesMetadataResultSpec()
        meta.includeTitle = True
        meta.includeContentLength = True
        meta.includeCreated = True
        meta.includeUpdated = True
        meta.includeNotebookGuid = True
        meta.includeAttributes = True
        meta.includeTagGuids = True
        meta.includeLargestResourceMime = True
        meta.includeLargestResourceSize = True

        result = self.getNoteStore().findNotesMetadata(self.authToken, noteFilter, offset, count, meta)

        # Reduces the count by the amount of notes already retrieved
        count = max(count - len(result.notes), 0)

        # Evernote api will only return so many notes in one go. Checks for more
        # notes to come whilst obeying count rules
        while ((result.totalNotes != len(result.notes)) and count != 0):
            offset = len(result.notes)
            result.notes += self.getNoteStore().findNotesMetadata(self.authToken, noteFilter, offset, count, meta).notes
            count = max(count - len(result.notes), 0)

        return result
Ejemplo n.º 2
0
    def findNotes(self, notebookId):
        """Fina all notes of a notebook

        Args:
            notebookId (str): notebook id
                eg: '9bf6cecf-d91e-4391-a034-199c744424db'
        Returns:
            Note list
        Raises:
        """
        logging.debug("notebookId=%s", notebookId)
        # find all notes in notebook
        searchOffset = 0
        # searchPageSize = 1000
        # searchPageSize = 5000
        searchPageSize = self.searchPageSize
        searchFilter = NoteStore.NoteFilter()
        searchFilter.order = NoteSortOrder.UPDATED
        searchFilter.ascending = False
        searchFilter.notebookGuid = notebookId
        logging.debug("searchFilter=%s", searchFilter)
        resultSpec = NotesMetadataResultSpec()
        resultSpec.includeTitle = True
        resultSpec.includeContentLength = True
        resultSpec.includeCreated = True
        resultSpec.includeUpdated = True
        resultSpec.includeDeleted = True
        resultSpec.includeNotebookGuid = True
        resultSpec.includeTagGuids = True
        resultSpec.includeAttributes = True
        resultSpec.includeLargestResourceMime = True
        resultSpec.includeLargestResourceSize = True
        logging.debug("resultSpec=%s", resultSpec)

        # foundNoteResult = self.noteStore.findNotesMetadata(
        #     authenticationToken=self.authToken,
        #     filter=searchFilter,
        #     offset=searchOffset,
        #     maxNotes=pageSize,
        #     resultSpec=resultSpec
        # )
        foundNoteResult = self.noteStore.findNotesMetadata(
            self.authToken, searchFilter, searchOffset, searchPageSize,
            resultSpec)
        logging.debug("foundNoteResult=%s", foundNoteResult)
        totalNotes = foundNoteResult.totalNotes
        logging.info("Total %d notes for notebook of guid=%s", totalNotes,
                     notebookId)
        foundNoteList = foundNoteResult.notes
        return foundNoteList
Ejemplo n.º 3
0
    def findNotes(self, keywords, count, createOrder=False, offset=0):
        """ WORK WITH NOTES """
        noteFilter = NoteStore.NoteFilter(order=Types.NoteSortOrder.RELEVANCE)
        noteFilter.order = getattr(Types.NoteSortOrder, self.noteSortOrder)
        if createOrder:
            noteFilter.order = Types.NoteSortOrder.CREATED

        if keywords:
            noteFilter.words = keywords

        meta = NotesMetadataResultSpec()
        meta.includeTitle = True
        meta.includeContentLength = True
        meta.includeCreated = True
        meta.includeUpdated = True
        meta.includeNotebookGuid = True
        meta.includeAttributes = True
        meta.includeTagGuids = True
        meta.includeLargestResourceMime = True
        meta.includeLargestResourceSize = True

        result = self.getNoteStore().findNotesMetadata(self.authToken,
                                                       noteFilter, offset,
                                                       count, meta)

        # Reduces the count by the amount of notes already retrieved
        count = max(count - len(result.notes), 0)

        # Evernote api will only return so many notes in one go. Checks for more
        # notes to come whilst obeying count rules
        while ((result.totalNotes != len(result.notes)) and count != 0):
            offset = len(result.notes)
            result.notes += self.getNoteStore().findNotesMetadata(
                self.authToken, noteFilter, offset, count, meta).notes
            count = max(count - len(result.notes), 0)

        return result