(value)
Parse a url from a value.

    Accepts:
    * url("<url>")
    * url(  "<url>"  )
    * url('<url>')
    * url(  '<url>'  )
    * url(<url>)
    * url(  <url>  )
Parse a url from a value.
Parse a url from a value .
def uri(value):
    """Parse a url from a value.

    Accepts:
    * url("<url>")
    * url(  "<url>"  )
    * url('<url>')
    * url(  '<url>'  )
    * url(<url>)
    * url(  <url>  )
    """
    if isinstance(value, str):
        value = value.strip()
    else:
        raise ValueError('Value {value} must be a string')

    if value.startswith('url(') and value.endswith(')'):
        # Remove the 'url(' and ')'
        value = value[4:-1].strip()

        # Single quotes and optional spaces
        if value.startswith("'") and value.endswith("'"):
            return Uri(value[1:-1])
        # Double quotes and optional spaces
        elif value.startswith('"') and value.endswith('"'):
            # '("some.url")'
            return Uri(value[1:-1])
        # No quotes and optional spaces
        else:
            return Uri(value)

    raise ValueError('Invalid url %s' % value)
def uri ( value ) : if isinstance ( value , str ) : value = value . strip ( ) else : raise ValueError ( 'Value {value} must be a string' ) if value . startswith ( 'url(' ) and value . endswith ( ')' ) : # Remove the 'url(' and ')' value = value [ 4 : - 1 ] . strip ( ) # Single quotes and optional spaces if value . startswith ( "'" ) and value . endswith ( "'" ) : return Uri ( value [ 1 : - 1 ] ) # Double quotes and optional spaces elif value . startswith ( '"' ) and value . endswith ( '"' ) : # '("some.url")' return Uri ( value [ 1 : - 1 ] ) # No quotes and optional spaces else : return Uri ( value ) raise ValueError ( 'Invalid url %s' % value )