Ejemplo n.º 1
0
    def getTextDBDictRepr(self):
        """
                Header.getTextDBDictRepr

                Return a string representing the data in the TextDBDict format.
        """
        res = []

        res.append( "" )
        res.append( "" )

        res.append( HEADER_START )

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # first line :
        first_line = self.headerdata.artiname

        if self.headerdata.fullname is not None:
            first_line += " "
            first_line += HEADER_FULLNAME_START
            first_line += self.headerdata.fullname
            first_line += HEADER_FULLNAME_END

        if self.headerdata.sortingname is not None:
            first_line += " "
            first_line += HEADER_SORTINGNAME_START
            first_line += self.headerdata.sortingname
            first_line += HEADER_SORTINGNAME_END

        if self.headerdata.articlescategory is not None:
            first_line += " "
            first_line += HEADER_ARTCATEGORY_START
            first_line += self.headerdata.articlescategory
            first_line += HEADER_ARTCATEGORY_END

        res.append( first_line )

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # other lines :

        # blank line to set apart the first line and the other ones :
        if len(self.headerdata.informations) > 0:
            res.append("")

        for information in self.headerdata.informations:

            value = self.headerdata.informations[information]

            res.append( "{0} {1} {2}".format(information,
                                             HEADER_INFORMATIONS_SEPARATOR,
                                             value))

        res.append( HEADER_END )

        res.append( "" )
        res.append( "" )

        return NEWLINE.join(res)
Ejemplo n.º 2
0
    def getTextDBDictRepr(self):
        """
                Body.getTextDBDictRepr

                Return a string representing the data in the TextDBDict format.
        """
        res = []

        for entrydata in self.bodydata.getEntries():

            entry = Entry( errors = self.errors,
                           logotherasdata = self.logotherasdata )
            entry.setData( entrydata )
            res.append( entry.getTextDBDictRepr() )

        return NEWLINE.join(res)
Ejemplo n.º 3
0
    def getTextDBDictRepr(self):
        """
                Extract.getTextDBDictRepr

                Return a string representing the data in the TextDBDict format.
        """
        res = []

        res.append( "" )

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # text :
        text = Text( errors = self.errors )
        text.setData( self.extractdata.textdata )

        string = text.getTextDBDictRepr()
        string = self.addExtractPrefixBeforeEachLine( string )

        res.append( string )

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # workreference :
        if self.extractdata.workreferencedata is not None:

            workreference = WorkReference( errors = self.errors,
                                           logotherasdata = self.logotherasdata )
            workreference.setData( self.extractdata.workreferencedata )

            string = workreference.getTextDBDictRepr()
            string = self.addExtractPrefixBeforeEachLine( string )

            res.append( string )

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # transcription :
        if self.extractdata.transcriptiondata is not None:

            transcription = Transcription( errors = self.errors,
                                           logotherasdata = self.logotherasdata )
            transcription.setData( self.extractdata.transcriptiondata )

            string = transcription.getTextDBDictRepr()
            string = BODY_EXTRACT_TRANSCRIPTION_START + " " + string
            string = self.addExtractPrefixBeforeEachLine( string )

            res.append( string )

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # translation :
        if self.extractdata.translationdata is not None:

            translation = Translation( errors = self.errors )
            translation.setData( self.extractdata.translationdata )

            string = translation.getTextDBDictRepr()
            string = BODY_EXTRACT_TRANSLATION_START + " " + string
            string = self.addExtractPrefixBeforeEachLine( string )

            res.append( string )

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # commentary :
        if self.extractdata.commentarydata is not None:

            commentary = Commentary( errors = self.errors )
            commentary.setData( self.extractdata.commentarydata )

            string = commentary.getTextDBDictRepr()
            string = self.addExtractPrefixBeforeEachLine( string )

            res.append( string )

        res.append( "" )

        return NEWLINE.join(res)
Ejemplo n.º 4
0
    def getTextDBDictRepr(self):
        """
                Entry.getTextDBDictRepr

                Return a string representing the data in the TextDBDict format.
        """
        res = []

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # title :
        title = self.entrydata.title

        if title is not None:
            hlevel = HierarchicalLevel(errors = self.errors,
                formatstr = logotheras.options.OPTIONS["textdbdict::HLEVELformatrst by writing"])
            hlevel.setData( self.entrydata.hlevel )

            # entry to-be-duplicated ?
            # If so, let's removing the symbols before and after the string to-be-duplicated :
            if self.entrydata.entry_to_be_duplicated is not None:

                if self.entrydata.important_entry_to_be_dup:
                    # 'important' symbol :
                    dup_symbol = BODY_ARTICLE_TO_DUPLICATED_IMPORTANT
                else:
                    # 'normal' symbol :
                    dup_symbol = BODY_ARTICLE_TO_DUPLICATED_NOTIMPORTANT

                title = title.replace( self.entrydata.entry_to_be_duplicated,
                                       dup_symbol + \
                                       self.entrydata.entry_to_be_duplicated + \
                                       dup_symbol )

            # result added to <res> :
            string = "{0} {1}"
            res.append( string.format(hlevel.getTextDBDictRepr(),
                                      title))

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # text after the title :
        text = self.entrydata.text

        for line in text:
            if line != "":
                res.append(line)

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # if no extract, we add an empty line after the title and the text :
        if len(self.entrydata)==0:
            res.append("")

        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        # extracts :
        for extractdata in self.entrydata:

            extract = Extract(errors = self.errors,
                              logotherasdata = self.logotherasdata)
            extract.setData( extractdata )

            res.append( extract.getTextDBDictRepr() )

        return NEWLINE.join(res)