service load match authors

Bug #1689934 reported by maarts
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenLP
New
Low
Unassigned

Bug Description

the service_load function in mediaitem.py match authors with _authors_match function. If the authors string includes commas like this: "Text: Mr. X, Alan Cross", the _authors_match function fails. The json.load uses by default commas for separation and split(', ') isn't a good choose...

I'am a python noob, but here the modified function:

    def _authors_match(self, song, authors):
        """
        Checks whether authors from a song in the database match the authors of the song to be imported.

        :param song: A list of authors from the song in the database
        :param authors: A string with authors from the song to be imported
        :return: True when Authors do match, else False.
        """

        author_list = []
        for author in song.authors:
            author_list.append(author.display_name)
        authors_song = ', '.join(author_list)
        if authors_song == authors:
            return True
        else:
            return False

Please fix the bug!

Thanks

Revision history for this message
maarts (maarts) wrote :

the chronology of song.authors may be still a problem... or switch the json separator...

Revision history for this message
maarts (maarts) wrote :

a little bit better...

def _authors_match(self, song, authors):

        author_list = []
        for author in song.authors:
     author_list.append(author.display_name)
            if author.display_name in authors:
                author_list.remove(author.display_name)
            else:
                return False
        # List must be empty at the end
        return not author_list

Revision history for this message
maarts (maarts) wrote :

now better:

def _authors_match(self, song, authors):
        author_list = []
        for author in song.authors:
            author_list.append(author.display_name)
            if author.display_name not in authors:
                return False

        authors_song = ', '.join(author_list)
        return len(authors_song) == len(authors)

Phill (phill-ridout)
Changed in openlp:
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.