def OSX_NSURL_toLocalFile(url):
 if isinstance(url, QUrl):
  url = url.toString()
 if (not url.startswith('file:///.file/id=')):
  return ''
 from subprocess import Popen, PIPE, DEVNULL
 cmd = ['osascript', '-e', 'get POSIX path of POSIX file "{}"'.format(url)]
 with Popen(cmd, stdout=PIPE, stderr=DEVNULL) as p:
  return p.stdout.read().strip().decode()

def OSX_NSURL_toLocalFile ( url ) : if isinstance ( url , QUrl ) : url = url . toString ( ) if ( not url . startswith ( 'file:///.file/id=' ) ) : return '' from subprocess import Popen , PIPE , DEVNULL cmd = [ 'osascript' , '-e' , 'get POSIX path of POSIX file "{}"' . format ( url ) ] with Popen ( cmd , stdout = PIPE , stderr = DEVNULL ) as p : return p . stdout . read ( ) . strip ( ) . decode ( )
return os x nsurl file reference as local file path or if not nsurl .