def is_file_url ( url ) : from . misc import to_text if not url : return False if not isinstance ( url , six . string_types ) : try : url = getattr ( url , "url" ) except AttributeError : raise ValueError ( "Cannot parse url from unknown type: {0!r}" . format ( url ) ) url = to_text ( url , encoding = "utf-8" ) return urllib_parse . urlparse ( url . lower ( ) ) . scheme == "file"
python how to determine a string is a file path or url
Returns true if the given url is a file url
def is_file_url(url):
    """Returns true if the given url is a file url"""
    from .misc import to_text

    if not url:
        return False
    if not isinstance(url, six.string_types):
        try:
            url = getattr(url, "url")
        except AttributeError:
            raise ValueError("Cannot parse url from unknown type: {0!r}".format(url))
    url = to_text(url, encoding="utf-8")
    return urllib_parse.urlparse(url.lower()).scheme == "file"