
    g                     *   d Z ddlZddlmZmZmZ ddlmZ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
Zdeee
eef   ef      d	efdZdeee
eef   ef      d	efdZdeded	e
edf   fdZy)zQuery string handling.    N)IterableMappingSequence)TYPE_CHECKINGAnySupportsIntUnion)istr   )QUERY_PART_QUOTERQUERY_QUOTERvreturnc                 (   t        |       }|t        u rt        |       S t        |t              rt        rt        | t              sJ | S |t        u st        |t              rlt        rt        | t              sJ t        j                  |       rt        d      t        j                  |       rt        d      t        t        |             S |t        ur$t        |t              rt        t        |             S t        dj                  | |            )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
issubclassr   
isinstancefloatmathisinf
ValueErrorisnanboolr   	TypeErrorformat)r   clss     @/var/www/openai/venv/lib/python3.12/site-packages/yarl/_query.py	query_varr       s    
q'C
cz1v#sa%%%
e|z#u-a'''::a=<==::a=<==58}
$:c;73q6{
	VAs^     itemsc                 &   t         }| D cg c]e  \  }}t        |      t        urt        |t        t
        f      r|n|fD ]1  } ||       d |t        |      t        u r|n
t        |             3 g }}}}dj                  |      S c c}}}w )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.
    =&)r   r   r   r   listtupler    join)r"   quoterkvalr   pairss         r   $get_str_query_from_sequence_iterabler-   ,   s     F FAs9C'JsT5M,JCQTPVV  !9+Qv47c>ay|DEF W 	G 
  88E?s   A*Bc                     t         }| D cg c]4  \  }} ||       d |t        |      t        u r|n
t        |             6 }}}dj	                  |      S c c}}w )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`.
    r$   r%   )r   r   r   r    r(   )r"   r)   r*   r   r,   s        r   get_str_query_from_iterabler/   @   sh     F TYSX41a6!9+Qv47c>ay|DEFSX 
  88E?s   9Aargskwargsc                     |r| rd}t        |      |}nt        |       dk(  r| d   }nt        d      |y|syt        |      t        u rt	        |j                               S t        |      t        u st        |t              rt        |      S t        |t              rt	        |j                               S t        |t        t        t        f      rd}t        |      t        |t              rt        |      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   r/   )r0   r1   msgquerys       r   get_str_queryr;   S   s     KCS/!	TaQRSS}E{d3EKKMBBE{cZs3E""%!3EKKMBB%%J78Qn%"
 +511
	4 r!   )__doc__r   collections.abcr   r   r   typingr   r   r   r	   	multidictr
   _quotersr   r   r   r   r   SimpleQueryQueryVariabler'   Queryr    r-   r/   r;    r!   r   <module>rE      s      7 7 9 9  5CeO$k8K#889#wsM)*HU3;M5N,OO	
 3 4E%T	*M9:;(E%T	*K789&# # #c4i0@ #r!   