
    01i1                     N    S r SSKJr  SSKJr  SSKJr  SSKJr   " S S\5      rg)	z6Module containing the logic for the URIBuilder object.   )compat)normalizers)uri)uri_referencec                       \ rS rSrSr       SS jrS r\S 5       rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rSrg)
URIBuilder   zObject to aid in building up a URI Reference from parts.

.. note::

    This object should be instantiated by the user, but it's recommended
    that it is not provided with arguments. Instead, use the available
    method to populate the fields.

Nc                 X    Xl         X l        X0l        X@l        XPl        X`l        Xpl        g)a  Initialize our URI builder.

:param str scheme:
    (optional)
:param str userinfo:
    (optional)
:param str host:
    (optional)
:param int port:
    (optional)
:param str path:
    (optional)
:param str query:
    (optional)
:param str fragment:
    (optional)
Nschemeuserinfohostportpathqueryfragment)selfr   r   r   r   r   r   r   s           I/home/james-whalen/.local/lib/python3.13/site-packages/rfc3986/builder.py__init__URIBuilder.__init__!   s'    6  			
     c                 $    SnUR                  U S9$ )z0Provide a convenient view of our builder object.zURIBuilder(scheme={b.scheme}, userinfo={b.userinfo}, host={b.host}, port={b.port}, path={b.path}, query={b.query}, fragment={b.fragment}))b)format)r   	formatstrs     r   __repr__URIBuilder.__repr__D   s"    6 	
 $''r   c           
          [        U[        R                  5      (       d  [        U5      nU " UR                  UR
                  UR                  UR                  UR                  UR                  UR                  S9$ )zInitialize the URI builder from another URI.

Takes the given URI reference and creates a new URI builder instance
populated with the values from the reference. If given a string it will
try to convert it to a reference before constructing the builder.
r   )
isinstancer   URIReferencer   r   r   r   r   r   r   r   )cls	references     r   from_uriURIBuilder.from_uriM   se     )S%5%566%i0I##''//''
 	
r   c           
          [         R                  " U5      n[        UU R                  U R                  U R
                  U R                  U R                  U R                  S9$ )a[  Add a scheme to our builder object.

After normalizing, this will generate a new URIBuilder instance with
the specified scheme and all other attributes the same.

.. code-block:: python

    >>> URIBuilder().add_scheme('HTTPS')
    URIBuilder(scheme='https', userinfo=None, host=None, port=None,
            path=None, query=None, fragment=None)

r   )	r   normalize_schemer   r   r   r   r   r   r   )r   r   s     r   
add_schemeURIBuilder.add_schemea   sN     --f5]]**]]
 	
r   c           
      2   Uc  [        S5      e[        R                  " U5      nUb&  SR                  U[        R                  " U5      5      n[        U R                  UU R                  U R                  U R                  U R                  U R                  S9$ )a  Add credentials as the userinfo portion of the URI.

.. code-block:: python

    >>> URIBuilder().add_credentials('root', 's3crete')
    URIBuilder(scheme=None, userinfo='root:s3crete', host=None,
            port=None, path=None, query=None, fragment=None)

    >>> URIBuilder().add_credentials('root', None)
    URIBuilder(scheme=None, userinfo='root', host=None,
            port=None, path=None, query=None, fragment=None)
zUsername cannot be Nonez{}:{}r   )
ValueErrorr   normalize_usernamer   normalize_passwordr   r   r   r   r   r   r   )r   usernamepasswordr   s       r   add_credentialsURIBuilder.add_credentialsy   s     67711(;~~..x8H
 ;;**]]
 	
r   c           
          [        U R                  U R                  [        R                  " U5      U R
                  U R                  U R                  U R                  S9$ )zAdd hostname to the URI.

.. code-block:: python

    >>> URIBuilder().add_host('google.com')
    URIBuilder(scheme=None, userinfo=None, host='google.com',
            port=None, path=None, query=None, fragment=None)

r   )	r   r   r   r   normalize_hostr   r   r   r   )r   r   s     r   add_hostURIBuilder.add_host   sI     ;;]]++D1**]]
 	
r   c           
      L   [        U5      nUS:  a  [        SR                  U5      5      eUS:  a  [        SR                  U5      5      e[        U R                  U R
                  U R                  SR                  U5      U R                  U R                  U R                  S9$ )a\  Add port to the URI.

.. code-block:: python

    >>> URIBuilder().add_port(80)
    URIBuilder(scheme=None, userinfo=None, host=None, port='80',
            path=None, query=None, fragment=None)

    >>> URIBuilder().add_port(443)
    URIBuilder(scheme=None, userinfo=None, host=None, port='443',
            path=None, query=None, fragment=None)

    z5ports are not allowed to be negative. You provided {}i  z>ports are not allowed to be larger than 65535. You provided {}z{}r   )
intr*   r   r   r   r   r   r   r   r   )r   r   port_ints      r   add_portURIBuilder.add_port   s     t9a<GNN 
 e""(&#  ;;]]X&**]]
 	
r   c           
         UR                  S5      (       d  SR                  U5      n[        U R                  U R                  U R
                  U R                  [        R                  " U5      U R                  U R                  S9$ )a  Add a path to the URI.

.. code-block:: python

    >>> URIBuilder().add_path('sigmavirus24/rfc3985')
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path='/sigmavirus24/rfc3986', query=None, fragment=None)

    >>> URIBuilder().add_path('/checkout.php')
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path='/checkout.php', query=None, fragment=None)

/z/{}r   )
startswithr   r   r   r   r   r   r   normalize_pathr   r   )r   r   s     r   add_pathURIBuilder.add_path   sf     s##<<%D;;]]++D1**]]
 	
r   c                     U R                   =(       d    SnSR                  UR                  S5      UR                  S5      5      nU R	                  U5      $ )az  Extend the existing path value with the provided value.

.. versionadded:: 1.5.0

.. code-block:: python

    >>> URIBuilder(path="/users").extend_path("/sigmavirus24")
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path='/users/sigmavirus24', query=None, fragment=None)

    >>> URIBuilder(path="/users/").extend_path("/sigmavirus24")
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path='/users/sigmavirus24', query=None, fragment=None)

    >>> URIBuilder(path="/users/").extend_path("sigmavirus24")
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path='/users/sigmavirus24', query=None, fragment=None)

    >>> URIBuilder(path="/users").extend_path("sigmavirus24")
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path='/users/sigmavirus24', query=None, fragment=None)

 z{}/{}r<   )r   r   rstriplstripr?   )r   r   existing_paths      r   extend_pathURIBuilder.extend_path   sD    0 		R~~m2237S9IJ}}T""r   c           
          [         R                  " [        R                  " U5      5      n[	        U R
                  U R                  U R                  U R                  U R                  UU R                  S9$ )a  Generate and add a query a dictionary or list of tuples.

.. code-block:: python

    >>> URIBuilder().add_query_from({'a': 'b c'})
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path=None, query='a=b+c', fragment=None)

    >>> URIBuilder().add_query_from([('a', 'b c')])
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path=None, query='a=b+c', fragment=None)

r   )r   normalize_queryr   	urlencoder   r   r   r   r   r   r   )r   query_itemsr   s      r   add_query_fromURIBuilder.add_query_from  sY     ++F,<,<[,IJ;;]]]]
 	
r   c                     [         R                  " U R                  =(       d    S5      n[        U[        5      (       d  [	        UR                  5       5      nU R                  X!-   5      $ )a  Extend the existing query string with the new query items.

.. versionadded:: 1.5.0

.. code-block:: python

    >>> URIBuilder(query='a=b+c').extend_query_with({'a': 'b c'})
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path=None, query='a=b+c&a=b+c', fragment=None)

    >>> URIBuilder(query='a=b+c').extend_query_with([('a', 'b c')])
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path=None, query='a=b+c&a=b+c', fragment=None)
rB   )r   	parse_qslr   r   listitemsrL   )r   rK   original_query_itemss      r   extend_query_withURIBuilder.extend_query_with'  sS      &//

0@bA+t,,{0023K""#7#EFFr   c           
          [        U R                  U R                  U R                  U R                  U R
                  [        R                  " U5      U R                  S9$ )zAdd a pre-formated query string to the URI.

.. code-block:: python

    >>> URIBuilder().add_query('a=b&c=d')
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path=None, query='a=b&c=d', fragment=None)

r   )	r   r   r   r   r   r   r   rI   r   )r   r   s     r   	add_queryURIBuilder.add_query<  sI     ;;]]--e4]]
 	
r   c                     [        U R                  U R                  U R                  U R                  U R
                  U R                  [        R                  " U5      S9$ )zAdd a fragment to the URI.

.. code-block:: python

    >>> URIBuilder().add_fragment('section-2.6.1')
    URIBuilder(scheme=None, userinfo=None, host=None, port=None,
            path=None, query=None, fragment='section-2.6.1')

r   )	r   r   r   r   r   r   r   r   normalize_fragment)r   r   s     r   add_fragmentURIBuilder.add_fragmentP  sI     ;;]]** 33H=
 	
r   c                     [         R                  " U R                  [        R                  " U R
                  U R                  U R                  45      U R                  U R                  U R                  5      $ )a  Create a URIReference from our builder.

.. code-block:: python

    >>> URIBuilder().add_scheme('https').add_host('github.com'
    ...     ).add_path('sigmavirus24/rfc3986').finalize().unsplit()
    'https://github.com/sigmavirus24/rfc3986'

    >>> URIBuilder().add_scheme('https').add_host('github.com'
    ...     ).add_path('sigmavirus24/rfc3986').add_credentials(
    ...     'sigmavirus24', 'not-re@l').finalize().unsplit()
    'https://sigmavirus24:not-re%40l@github.com/sigmavirus24/rfc3986'

)r   r    r   r   normalize_authorityr   r   r   r   r   r   r   s    r   finalizeURIBuilder.finalized  sY     KK++		4995 IIJJMM
 	
r   c                 >    U R                  5       R                  5       $ )zGenerate the URL from this builder.

.. versionadded:: 1.5.0

This is an alternative to calling :meth:`finalize` and keeping the
:class:`rfc3986.uri.URIReference` around.
)r_   unsplitr^   s    r   geturlURIBuilder.geturl}  s     }}&&((r   )r   r   r   r   r   r   r   )NNNNNNN)__name__
__module____qualname____firstlineno____doc__r   r   classmethodr#   r'   r/   r3   r9   r?   rF   rL   rS   rV   rZ   r_   rc   __static_attributes__ r   r   r   r      s|     !!F( 
 
&
0
B
(%
N
6#:
4G*
(
(
2)r   r   N)ri   rB   r   r   r   r   objectr   rl   r   r   <module>rn      s$    =    o) o)r   