#NEWLINE# def as_url( s ) : #NEWLINE# #INDENT# 'Tries to convert the input into a proper URL.' #NEWLINE# url_parts = urlsplit ( s ) #NEWLINE# if ( ( len ( url_parts . scheme ) == 1 ) and url_parts . scheme . isalpha ( ) ) : #NEWLINE# #INDENT# return ( 'file:///%s' % str ( s ) . replace ( '\\' , '/' ) ) #NEWLINE# #UNINDENT# if url_parts . scheme : #NEWLINE# #INDENT# return url_parts . geturl ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( 'file://%s' % str ( url_parts ) )