<s> from __future__ import absolute_import , unicode_literals <EOL> import logging <EOL> import os <EOL> import urllib <EOL> from mopidy import compat <EOL> from mopidy . internal import path <EOL> logger = logging . getLogger ( __name__ ) <EOL> def local_uri_to_file_uri ( uri , media_dir ) : <EOL> """<STR_LIT>""" <EOL> return path_to_file_uri ( local_uri_to_path ( uri , media_dir ) ) <EOL> def local_uri_to_path ( uri , media_dir ) : <EOL> """<STR_LIT>""" <EOL> if ( <EOL> not uri . startswith ( '<STR_LIT>' ) and <EOL> not uri . startswith ( '<STR_LIT>' ) ) : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> file_path = path . uri_to_path ( uri ) . split ( b'<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] <EOL> return os . path . join ( media_dir , file_path ) <EOL> def local_track_uri_to_path ( uri , media_dir ) : <EOL> return local_uri_to_path ( uri , media_dir ) <EOL> def path_to_file_uri ( abspath ) : <EOL> """<STR_LIT>""" <EOL> return path . path_to_uri ( abspath ) <EOL> def path_to_local_track_uri ( relpath ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( relpath , compat . text_type ) : <EOL> relpath = relpath . encode ( '<STR_LIT:utf-8>' ) <EOL> return '<STR_LIT>' % urllib . quote ( relpath ) <EOL> def path_to_local_directory_uri ( relpath ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( relpath , compat . text_type ) : <EOL> relpath = relpath . encode ( '<STR_LIT:utf-8>' ) <EOL> return '<STR_LIT>' % urllib . quote ( relpath ) </s>
