<s> from __future__ import absolute_import , unicode_literals <EOL> import logging <EOL> from mopidy import listener , models <EOL> logger = logging . getLogger ( __name__ ) <EOL> class Backend ( object ) : <EOL> """<STR_LIT>""" <EOL> audio = None <EOL> library = None <EOL> playback = None <EOL> playlists = None <EOL> uri_schemes = [ ] <EOL> def has_library ( self ) : <EOL> return self . library is not None <EOL> def has_library_browse ( self ) : <EOL> return self . has_library ( ) and self . library . root_directory is not None <EOL> def has_playback ( self ) : <EOL> return self . playback is not None <EOL> def has_playlists ( self ) : <EOL> return self . playlists is not None <EOL> def ping ( self ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> class LibraryProvider ( object ) : <EOL> """<STR_LIT>""" <EOL> pykka_traversable = True <EOL> root_directory = None <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , backend ) : <EOL> self . backend = backend <EOL> def browse ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> return [ ] <EOL> def get_distinct ( self , field , query = None ) : <EOL> """<STR_LIT>""" <EOL> return set ( ) <EOL> def get_images ( self , uris ) : <EOL> """<STR_LIT>""" <EOL> result = { } <EOL> for uri in uris : <EOL> image_uris = set ( ) <EOL> for track in self . lookup ( uri ) : <EOL> if track . album and track . album . images : <EOL> image_uris . update ( track . album . images ) <EOL> result [ uri ] = [ models . Image ( uri = u ) for u in image_uris ] <EOL> return result <EOL> def lookup ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def refresh ( self , uri = None ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def search ( self , query = None , uris = None , exact = False ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class PlaybackProvider ( object ) : <EOL> """<STR_LIT>""" <EOL> pykka_traversable = True <EOL> def __init__ ( self , audio , backend ) : <EOL> self . audio = audio <EOL> self . backend = backend <EOL> def pause ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . audio . pause_playback ( ) . get ( ) <EOL> def play ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . audio . start_playback ( ) . get ( ) <EOL> def prepare_change ( self ) : <EOL> """<STR_LIT>""" <EOL> self . audio . prepare_change ( ) . get ( ) <EOL> def translate_uri ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> return uri <EOL> def change_track ( self , track ) : <EOL> """<STR_LIT>""" <EOL> uri = self . translate_uri ( track . uri ) <EOL> if uri != track . uri : <EOL> logger . debug ( <EOL> '<STR_LIT>' , track . uri , uri ) <EOL> if not uri : <EOL> return False <EOL> self . audio . set_uri ( uri ) . get ( ) <EOL> return True <EOL> def resume ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . audio . start_playback ( ) . get ( ) <EOL> def seek ( self , time_position ) : <EOL> """<STR_LIT>""" <EOL> return self . audio . set_position ( time_position ) . get ( ) <EOL> def stop ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . audio . stop_playback ( ) . get ( ) <EOL> def get_time_position ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . audio . get_position ( ) . get ( ) <EOL> class PlaylistsProvider ( object ) : <EOL> """<STR_LIT>""" <EOL> pykka_traversable = True <EOL> def __init__ ( self , backend ) : <EOL> self . backend = backend <EOL> def as_list ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def get_items ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def create ( self , name ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def delete ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def lookup ( self , uri ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def refresh ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def save ( self , playlist ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> class BackendListener ( listener . Listener ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def send ( event , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> listener . send ( BackendListener , event , ** kwargs ) <EOL> def playlists_loaded ( self ) : <EOL> """<STR_LIT>""" <EOL> pass </s>
