예제 #1
0
    def readVersion(self, noteId):
        '''
        outputs the content of a note version
        :param noteId:
        :return:
        '''
        if self._swiftManager.doesNoteExist(noteId) == True:
            note, title, versions, noteList = self._versionMngr._getVersionInfo(
                noteId)

            # user input for id, if the input is not an integer the error
            # message will be displayed
            try:
                readingVersion = int(
                    raw_input("Which version do you wish to read (id)? >"))
            except (ValueError):
                print "invalid input"
                sys.exit(1)

            for key, value in versions.iteritems():
                self._keyList.append(key)
                if key == readingVersion:
                    versionTitle = versions[key][1]
                    # get the content of the object
                    content = noteList[versionTitle]
                    # create the note title, composing from "vTIMESTAMP-id -
                    # title"
                    noteTitle = versionTitle + \
                        OutputManager.ID_TITLE_SEPERATOR + title

                    OutputManager.markdownPrint(noteTitle, content)
                else:
                    continue
            # as an information for the user, that the version doesn't exist
            if readingVersion not in self._keyList:
                print str(readingVersion) + " doesn't exist"
        # as an information for the user, that the note doesn't exist
        else:
            print "Note #" + str(noteId) + " doesn't exist"
예제 #2
0
 def _readNote(self, note):
     OutputManager.markdownPrint(note.getTitle(), note.getContent())