def searchResultsToDefinitionThree(searchResults, modulesInfo): assert len(searchResults) > 0 uniqueArtists = {} for result in searchResults: artist = string.lower(result[ARTIST_IDX]) if uniqueArtists.has_key(artist): uniqueArtists[artist].append(result) else: uniqueArtists[artist] = [result] df = Definition() for (artist, songs) in uniqueArtists.items(): artist = songs[0][ARTIST_IDX] df.TextElement("Songs by ") gtxt = df.TextElement(artist) setArtistLink(gtxt, artist, modulesInfo) df.TextElement(":") for song in songs: title = song[TITLE_IDX] artist = song[ARTIST_IDX] lyricsId = song[LYRIC_ID_IDX] df.BulletElement(False) gtxt = df.TextElement(title) gtxt.setHyperlink("s+lyricsitem:" + lyricsId) gtxt.setStyle('bold') df.PopParentElement() df.LineBreakElement() gtxt = df.TextElement("New Search") gtxt.setHyperlink("lyricsform:search") gtxt.setJustification(justCenter) return df
def searchResultsToDefinitionTwo(searchResults, modulesInfo): assert len(searchResults) > 0 df = Definition() df.TextElement("Search results:") for result in searchResults: title = result[TITLE_IDX] artist = result[ARTIST_IDX] lyricsId = result[LYRIC_ID_IDX] df.BulletElement(False) df.TextElement(title, link="s+lyricsitem:" + lyricsId, style='bold') df.TextElement(" by ") gtxt = df.TextElement(artist) setArtistLink(gtxt, artist, modulesInfo) df.PopParentElement() df.LineBreakElement() gtxt = df.TextElement("New Search") gtxt.setHyperlink("lyricsform:search") gtxt.setJustification(justCenter) return df