#NEWLINE# def is_url( s ) : #NEWLINE# #INDENT# 'Return True if the string appears to be a valid URL.' #NEWLINE# if isinstance ( s , six . string_types ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# url_parts = urlsplit ( s ) #NEWLINE# if ( ( len ( url_parts . scheme ) == 1 ) and url_parts . scheme . isalpha ( ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( ( url_parts . scheme == 'file' ) and bool ( url_parts . path ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# return ( bool ( url_parts . scheme ) and bool ( url_parts . netloc ) ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# return False