def encode(url):
    """Encode URL."""
    parts = extract(url)
    return construct(URL(parts.scheme,
                         parts.username,
                         parts.password,
                         _idna_encode(parts.subdomain),
                         _idna_encode(parts.domain),
                         _idna_encode(parts.tld),
                         parts.port,
                         quote(parts.path.encode('utf-8')),
                         _encode_query(parts.query),
                         quote(parts.fragment.encode('utf-8')),
                         None))
def encode ( url ) : parts = extract ( url ) return construct ( URL ( parts . scheme , parts . username , parts . password , _idna_encode ( parts . subdomain ) , _idna_encode ( parts . domain ) , _idna_encode ( parts . tld ) , parts . port , quote ( parts . path . encode ( 'utf-8' ) ) , _encode_query ( parts . query ) , quote ( parts . fragment . encode ( 'utf-8' ) ) , None ) )
Encode URL.