<s> import logging <EOL> from pylons import request , response , session <EOL> from pylons import tmpl_context as c <EOL> from pylons . controllers . util import abort <EOL> from pylons import app_globals as g <EOL> from theory . lib . base import BaseController , render <EOL> from theory . model . mpdpool import NoMPDConnection <EOL> log = logging . getLogger ( __name__ ) <EOL> class PlaylistController ( BaseController ) : <EOL> requires_auth = True <EOL> def index ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . m = g . p . connect ( ) <EOL> except NoMPDConnection : <EOL> return render ( '<STR_LIT>' ) <EOL> status = self . m . status ( ) <EOL> c . playlistid = status [ '<STR_LIT>' ] <EOL> c . playlist = self . m . playlistinfo ( ) <EOL> info = self . m . lsinfo ( ) <EOL> c . available_playlists = [ playlist [ '<STR_LIT>' ] for playlist in info if '<STR_LIT>' in playlist ] <EOL> c . available_playlists . insert ( <NUM_LIT:0> , '<STR_LIT>' ) <EOL> c . g = g <EOL> return render ( '<STR_LIT>' ) <EOL> def save ( self ) : <EOL> """<STR_LIT>""" <EOL> name = request . GET . get ( '<STR_LIT:name>' , <NUM_LIT:0> ) <EOL> if name == <NUM_LIT:0> : <EOL> return '<STR_LIT>' <EOL> self . m = g . p . connect ( ) <EOL> info = self . m . lsinfo ( ) <EOL> available_playlists = [ playlist [ '<STR_LIT>' ] for playlist in info if '<STR_LIT>' in playlist ] <EOL> if name in available_playlists : <EOL> self . m . rm ( name ) <EOL> self . m . save ( name ) <EOL> return '<STR_LIT>' <EOL> def load ( self ) : <EOL> """<STR_LIT>""" <EOL> name = request . GET . get ( '<STR_LIT:name>' , <NUM_LIT:0> ) <EOL> if name == <NUM_LIT:0> : <EOL> return '<STR_LIT>' <EOL> self . m = g . p . connect ( ) <EOL> self . m . load ( name ) <EOL> return '<STR_LIT>' <EOL> def delete ( self ) : <EOL> """<STR_LIT>""" <EOL> name = request . GET . get ( '<STR_LIT:name>' , <NUM_LIT:0> ) <EOL> if name == <NUM_LIT:0> : <EOL> return '<STR_LIT>' <EOL> self . m = g . p . connect ( ) <EOL> self . m . rm ( name ) <EOL> return '<STR_LIT>' </s>
