def loadPlaylist (self, source): if not path.exists (self.configDir): os.makedirs (self.configDir) p = xspf.Playlist (title=_("Serpentine's playlist"), creator="Serpentine " + self.version) try: p.parse (path.join (self.configDir, "playlist.xml")) except IOError: return source.from_playlist (p)
def savePlaylist (self, source): if not path.exists (self.configDir): os.makedirs (self.configDir) p = xspf.Playlist (title=_("Serpentine's playlist"), creator="Serpentine " + self.version) source.to_playlist (p) doc = p.toxml() out = SafeFileWrite (path.join (self.configDir, "playlist.xml")) try: doc.writexml (out, addindent = "\t", newl = "\n") del p out.close() except: out.abort () return False return True