#NEWLINE# def file_url_to_path( url , verify_exists = False ) : #NEWLINE# #INDENT# '\n    Convert a file URL to a path, handling some odd cases around Windows paths.\n\n    :param url: a file URL\n    :param verify_exists: If true, return an populated dict only if the\n                          resulting file path exists on the local file system.\n\n    :returns: a dict containing keys `path`, `files` and `cacheDir` or an empty\n              dict if the URL is not a file URL.\n    ' #NEWLINE# parts = urlsplit ( url ) #NEWLINE# if ( ( parts . scheme == 'file' ) or ( parts . scheme == '' ) ) : #NEWLINE# #INDENT# path = parts . path #NEWLINE# if re . match ( '\\/[A-Za-z]:' , path ) : #NEWLINE# #INDENT# path = path [ 1 : ] #NEWLINE# #UNINDENT# if ( os . path . exists ( path ) or ( not verify_exists ) ) : #NEWLINE# #INDENT# return { #NEWLINE# #INDENT# 'path' : path , #NEWLINE# 'files' : [ os . path . basename ( path ) ] , #NEWLINE# 'cacheDir' : os . path . dirname ( path ) , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# }