def readPlaylistFromDB(): playlistDict = {} effectivePlaylist = DBProcess.getEffectivePlaylist() for pid in effectivePlaylist.keys(): pList = Playlist(pid,effectivePlaylist[pid]) playlistDict[pid] = pList print 'Thare are %d playlist have been read.' % len(playlistDict) return playlistDict
def writePlaylistsToFile(): filename = "txt/playlists.txt" if os.path.exists(filename): print '%s is existing......' % filename return else: print 'Begin to write playlists......' pFile = open(filename,"w") effectivePlaylist = DBProcess.getEffectivePlaylist() for pid in effectivePlaylist.keys(): pList = effectivePlaylist[pid] content = "%d:" % pid count = len(pList) for i in range(0,count-1): content = "%s%d," % (content,pList[i]) content = "%s%d" % (content,pList[count-1]) pFile.write(content+'\n') pFile.close() print 'End of writing playlists......'