o
    h+                     @   s  d Z ddlZddlmZmZmZ ddlmZmZm	Z	 ddl
mZ ddlmZmZ e	eeef Ze	eee f Ze	deeeef eeeef  f Zded	efd
dZdeee	eef ef  d	efddZdeee	eef ef  d	efddZdeded	e	edf fddZdS )zQuery string handling.    N)IterableMappingSequence)AnySupportsIntUnion)istr   )QUERY_PART_QUOTERQUERY_QUOTERvreturnc                 C   s   t | }|tu rt| S t| tr| S t| tr0t| r!tdt| r*tdtt| S |t	ur?t| t
r?tt| S td| |)z%Convert a query variable to a string.zfloat('inf') is not supportedzfloat('nan') is not supportedzMInvalid variable type: value should be str, int or float, got {!r} of type {})typeintstr
isinstancefloatmathisinf
ValueErrorisnanboolr   	TypeErrorformat)r   cls r   _/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/yarl/_query.py	query_var   s"   



r   itemsc                        t   fdd| D }d|S )zReturn a query string from a sequence of (key, value) pairs.

    value is a single value or a sequence of values for the key

    The sequence of values must be a list or tuple.
    c                    sd   g | ].\}}t |turt|ttfr|n|fD ]} | d  t |tu r(|nt| qqS =)r   r   r   listtupler   ).0kvalr   quoterr   r   
<listcomp>2   s    "(z8get_str_query_from_sequence_iterable.<locals>.<listcomp>&r
   joinr   pairsr   r'   r   $get_str_query_from_sequence_iterable(   s
   	

r/   c                    r   )zReturn a query string from an iterable.

    The iterable must contain (key, value) pairs.

    The values are not allowed to be sequences, only single values are
    allowed. For sequences, use `_get_str_query_from_sequence_iterable`.
    c                    s:   g | ]\}} | d  t |tu r|nt| qS r    )r   r   r   )r$   r%   r   r'   r   r   r)   I   s    .z/get_str_query_from_iterable.<locals>.<listcomp>r*   r+   r-   r   r'   r   get_str_query_from_iterable<   s
   


r0   argskwargsc                  O   s   |r| r
d}t ||}nt| dkr| d }nt d|du r"dS |s&dS t|tu r2t| S t|tu s=t|trAt|S t|t	rLt| S t|t
ttfrZd}t|t|trct|S td)z*Return a query string from supported args.z7Either kwargs or single query parameter must be presentr	   r   N zAInvalid query type: bytes, bytearray and memoryview are forbiddenzRInvalid query type: only str, mapping or sequence of (key, value) pairs is allowed)r   lenr   dictr/   r   r   r   r   r   bytes	bytearray
memoryviewr   r   r0   )r1   r2   msgqueryr   r   r   get_str_queryO   s4   


r;   )__doc__r   collections.abcr   r   r   typingr   r   r   	multidictr   _quotersr
   r   r   r   SimpleQueryQueryVariabler#   Queryr   r/   r0   r;   r   r   r   r   <module>   s.    

"