Checks if a given string is an url

def is_valid_url(url):
    """Checks if a given string is an url"""
    from .misc import to_text

    if not url:
        return url
    pieces = urllib_parse.urlparse(to_text(url))
    return all([pieces.scheme, pieces.netloc])