
    @6iJ                     6    d dl mZ d dlmZmZ  G d de      Zy)   )urlparse)	text_typeuc                       e Zd ZdZd Zed        Zed        Zd Z	d Z
ed        Zd Zd	 Zed
        Zd Zd Zed        Zd Zed        Zd Zd Zed        Zd Zy)Netlocz
    A netloc string (``username:password@hostname:port``).

    Contains methods for accessing and (non-destructively) modifying those four
    components of the netloc. All methods return new instances.
    c                 2    t        d      t        |       fz  S )Nz
Netloc(%r))r   r   selfs    S/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/urlobject/netloc.py__repr__zNetloc.__repr__   s    )D/!333    c                 Z    d}|r|}|r|d|z   z  }|dz  }d}|d|z  } | ||z   |z         S )z:Put together a :class:`Netloc` from its constituent parts. :@z:%d )clsusernamepasswordhostnameportauth_stringport_strings          r   	__unsplitzNetloc.__unsplit   sU     "KsX~-3K$,K;)K788r   c                 .    | j                   j                  S )z1The username portion of this netloc, or ``None``.)_Netloc__urlsplitr   r	   s    r   r   zNetloc.username        '''r   c                 &    | j                  |      S )z)Replace or add a username to this netloc.)r   _Netloc__replace)r
   r   s     r   with_usernamezNetloc.with_username$       ~~x~00r   c                 @    | j                         j                  d      S )z4Remove any username (and password) from this netloc.r   )without_passwordr!   r	   s    r   without_usernamezNetloc.without_username(   s    $$&44R88r   c                 .    | j                   j                  S )z1The password portion of this netloc, or ``None``.)r   r   r	   s    r   r   zNetloc.password,   r   r   c                 X    |r| j                   st        d      | j                  |      S )z
        Replace or add a password to this netloc.

        Raises a ``ValueError`` if you attempt to add a password to a netloc
        with no username.
        z1Can't set a password on a netloc with no username)r   )r   
ValueErrorr    )r
   r   s     r   with_passwordzNetloc.with_password1   s*     DMMPQQ~~x~00r   c                 $    | j                  d      S )z%Remove any password from this netloc.r   )r)   r	   s    r   r$   zNetloc.without_password>   s    !!"%%r   c                 2    | j                   | j                  fS )z6The username and password of this netloc as a 2-tuple.)r   r   r	   s    r   authzNetloc.authB   s     t}}--r   c                     | j                         }|r |j                  |      j                  | S |j                  |      S )z:Replace or add a username and password in one method call.)without_authr!   r)   )r
   r   r   netlocs       r   	with_authzNetloc.with_authG   sB    ""$?6''1??JJ##H--r   c                 >    | j                         j                         S )N)r$   r%   r	   s    r   r.   zNetloc.without_authN   s    $$&7799r   c                 .    | j                   j                  S )z$The hostname portion of this netloc.)r   r   r	   s    r   r   zNetloc.hostnameQ   r   r   c                 &    | j                  |      S )z$Replace the hostname on this netloc.)r   r   )r
   r   s     r   with_hostnamezNetloc.with_hostnameV   r"   r   c                 .    | j                   j                  S )z<The port number on this netloc (as an ``int``), or ``None``.)r   r   r	   s    r   r   zNetloc.portZ   s     ###r   c                 &    | j                  |      S )z,Replace or add a port number to this netloc.r   r   )r
   r   s     r   	with_portzNetloc.with_port_       ~~4~((r   c                 &    | j                  d      S )z(Remove any port number from this netloc.Nr7   r   r	   s    r   without_portzNetloc.without_portc   r9   r   c                 4    t        j                  d| ddd      S )Nr   )r   SplitResultr	   s    r   
__urlsplitzNetloc.__urlsplitg   s    ##Bb"b99r   c                     | j                   | j                  | j                  | j                  d}|j	                  |        | j
                  di |S )z0Replace any number of components on this netloc.)r   r   r   r   r   )r   r   r   r   update_Netloc__unsplit)r
   paramsunsplit_argss      r   	__replacezNetloc.__replacek   sI    $(MM$(MM$(MM $		+ 	F#t~~---r   N)__name__
__module____qualname____doc__r   classmethodrA   propertyr   r!   r%   r   r)   r$   r,   r0   r.   r   r4   r   r8   r;   r   r    r   r   r   r   r      s    4 9 9 ( (19 ( (1& . ..: ( (1 $ $)) : :.r   r   N)compatr   sixr   r   r   r   r   r   <module>rM      s     m.Y m.r   