def _getVersionInfo(self, noteId, output=True): ''' prints and returns a list of the versions of the given note :param noteId: :param output: :return: ''' # a list with a list of objects that start with "v" allVersions = self._downloadAllNoteVersions() self._swiftMngr.downloadNotes() # a list with the content for each object noteList = self._swiftMngr.getDownloadedNotes() note = self._swiftMngr.getNote(noteId) title = note.getTitle() # a list of all the versions with a continuos Id versions = self.historyList(noteId, self.arrangeNoteVersions(allVersions), title) # rearanges the ids so each note's versions start counting from 1 # rearangedVersions = self.rearangeVersionID(versions) if output: # nicely prints the versions list OutputManager.listPrint(versions, 3) return note, title, versions, noteList
def searchInTitle(self, subString): elementList = self._searchInTitleImpl(subString) elementDict = {} for elements in elementList: id = elements[0] elementDict[id] = elements sorted(elementDict) OutputManager.listPrint(elementDict, OutputManager.HEADER_FULL)
def listNotesAndMeta(self): list = self._swiftManager.downloadObjectIds() soDict = {} sort = Configuration.entriessort for element in list: # exclude versions and deleted notes, that always begin with 'v' if VersionManager.isVersionOrDeleted(element): continue id = SwiftManager.objIdToId(element) if id is None: raise RuntimeError( "Can not get the ID from " + element + " ... should not happen, really") metamngr = self._swiftManager.metaManagerFactory(element) id = int(id) crdate = metamngr.getCreateDate() lastmod = metamngr.getLastModifiedDate() tags = metamngr.getTags() name = SwiftManager.objIdToTitle(element) soDict[id] = [id, name, crdate, lastmod, tags] if sort == "name": soDict = OrderedDict( sorted( soDict.items(), key=lambda k_v: k_v[1][1])) elif sort == "crdate": soDict = OrderedDict( sorted( soDict.items(), key=lambda k_v1: datetime.strptime( k_v1[1][2], "%H:%M:%S, %d/%m/%Y").isoformat(), reverse=True)) elif sort == "id": sorted(soDict) else: soDict = OrderedDict( sorted( soDict.items(), key=lambda k_v2: datetime.strptime( k_v2[1][3], "%H:%M:%S, %d/%m/%Y").isoformat(), reverse=True)) OutputManager.listPrint(soDict, OutputManager.HEADER_FULL)
def searchInTags(self, substr): ''' for every object in list check for tags check if tags are the same if tags in element meta print element name ''' elementList = self._searchInTagsImpl(substr) dict = {} for elements in elementList: id = elements[0] dict[id] = elements sorted(dict) OutputManager.listPrint(dict, OutputManager.HEADER_TAG)
def printMeta(self, metaId): ''' prints the metadata of a single note :param metaId: :return: ''' dict = {} note = self.getNote(metaId) mm = self.metaManagerFactory(note.getObjectId()) name = SwiftManager.objIdToTitle(note.getObjectId()) crDate = mm.getCreateDate() lastmod = mm.getLastModifiedDate() tags = mm.getTags() dict[metaId] = [metaId, name, crDate, lastmod, tags] sorted(dict) OutputManager.listPrint(dict, OutputManager.HEADER_FULL)
def printMeta(self, metaId): ''' prints the metadata of a single note :param metaId: :return: ''' dict = {} note = self.getNote(metaId) mm = self.metaManagerFactory(note.getObjectId()) name = SwiftManager.objIdToTitle(note.getObjectId()) crDate = mm.getCreateDate() lastmod = mm.getLastModifiedDate() tags = mm.getTags() dict[metaId] = [metaId, name, crDate, lastmod, tags] sorted(dict) OutputManager.listPrint(dict, OutputManager.HEADER_FULL)
def getDeletedInfo(self, output=True): ''' prints and returns a list of backed up notes :param output: :return: ''' allDeleted = self._downloadAllDeleted() deletedList = {} deletedId = 0 for element in allDeleted: # assign an id to all objects and save it in a dict deletedId = deletedId + 1 deletedList[deletedId] = [deletedId, element] if output: # nicely prints the backed up notes list OutputManager.listPrint(deletedList, 4) return deletedList