
    }Wh1                     V    d Z ddlmZ ddlmZ ddlmZ ddlmZ  G d de          ZdS )	z6Module containing the logic for the URIBuilder object.   )compat)normalizers)uri)uri_referencec                       e Zd ZdZ	 	 	 	 	 	 	 ddZd Zed             Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd ZdS )
URIBuildera  Object 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                 h    || _         || _        || _        || _        || _        || _        || _        dS )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           U/var/www/html/movieo_spanner_bot/venv/lib/python3.11/site-packages/rfc3986/builder.py__init__zURIBuilder.__init__!   s9    6  			
     c                 2    d}|                     |           S )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__zURIBuilder.__repr__D   s%    6 	
 $'''r   c           	          t          |t          j                  st          |          } | |j        |j        |j        |j        |j        |j	        |j
                  S )a  Initialize 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_urizURIBuilder.from_uriM   se     )S%566 	1%i00Is#'/'
 
 
 	
r   c           	          t          j        |          }t          || j        | j        | j        | j        | j        | j                  S )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_schemezURIBuilder.add_schemea   sL     -f55]*]
 
 
 	
r   c           	         |t          d          t          j        |          }|(d                    |t          j        |                    }t          | j        || j        | j        | j	        | j
        | j                  S )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)
        NzUsername cannot be Nonez{}:{}r
   )
ValueErrorr   normalize_usernamer   normalize_passwordr   r   r   r   r   r   r   )r   usernamepasswordr   s       r   add_credentialszURIBuilder.add_credentialsy   s     67771(;;~~.x88 H
 ;*]
 
 
 	
r   c           	          t          | j        | j        t          j        |          | j        | j        | j        | j                  S )a  Add 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_hostzURIBuilder.add_host   sG     ;]+D11*]
 
 
 	
r   c           	      N   t          |          }|dk     r"t          d                    |                    |dk    r"t          d                    |                    t          | j        | j        | j        d                    |          | j        | j        | j	                  S )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_portzURIBuilder.add_port   s     t99a<<GNN   
 e""(&# #   ;]X&&*]
 
 
 	
r   c           	          |                     d          sd                    |          }t          | j        | j        | j        | j        t          j        |          | j	        | j
                  S )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_pathzURIBuilder.add_path   sl     s## 	&<<%%D;]+D11*]
 
 
 	
r   c                     | j         pd}d                    |                    d          |                    d                    }|                     |          S )a  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{}/{}r4   )r   r   rstriplstripr7   )r   r   existing_paths      r   extend_pathzURIBuilder.extend_path   sN    0 	R~~m22377S9I9IJJ}}T"""r   c           	          t          j        t          j        |                    }t	          | j        | j        | j        | j        | j	        || j
                  S )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_fromzURIBuilder.add_query_from  sW     +F,<[,I,IJJ;]]
 
 
 	
r   c                     t          j        | j        pd          }t          |t                    s!t	          |                                          }|                     ||z             S )a4  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)
        r9   )r   	parse_qslr   r   listitemsrB   )r   rA   original_query_itemss      r   extend_query_withzURIBuilder.extend_query_with'  sa      &/
0@bAA+t,, 	4{002233K""#7+#EFFFr   c           
          t          | j        | j        | j        | j        | j        t          j        |          | j                  S )a  Add 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   r?   r   )r   r   s     r   	add_queryzURIBuilder.add_query<  sG     ;]-e44]
 
 
 	
r   c                     t          | j        | j        | j        | j        | j        | j        t          j        |                    S )a  Add 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_fragmentzURIBuilder.add_fragmentP  sG     ;]* 3H==
 
 
 	
r   c                     t          j        | j        t          j        | j        | j        | j        f          | j        | j	        | j
                  S )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   finalizezURIBuilder.finalized  sO     K+	495  IJM
 
 	
r   c                 N    |                                                                  S )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.
        )rQ   unsplitrP   s    r   geturlzURIBuilder.geturl}  s     }}&&(((r   )NNNNNNN)__name__
__module____qualname____doc__r   r   classmethodr    r#   r*   r-   r2   r7   r=   rB   rH   rJ   rM   rQ   rT    r   r   r   r      s-         !! !! !! !!F( ( ( 
 
 [
&
 
 
0
 
 
B
 
 
(%
 %
 %
N
 
 
6# # #:
 
 
4G G G*
 
 
(
 
 
(
 
 
2) ) ) ) )r   r   N)rX   r9   r   r   r   r   objectr   rZ   r   r   <module>r\      s    = <                        o) o) o) o) o) o) o) o) o) o)r   