
    i                     .   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
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cast)istr   )QUERY_PART_QUOTERQUERY_QUOTERvreturnc                    t        |       }|t        u rt        |       S t        | t              r| S t        | t              rTt        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
isinstancefloatmathisinf
ValueErrorisnanboolr   	TypeErrorformat)r   clss     F/var/www/html/binance/venv/lib/python3.12/site-packages/yarl/_query.py	query_varr       s    
q'C
cz1v!S!U::a=<==::a=<==58}
$:a5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  As9C'JsT5M,JCQTPV	  !9+Qv47c>ay|DEFFE  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/   <   se     F TYKO1a6!9+Qv47c>ay|DEFE  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              rBt        r1t!        t        t"        t$        t        t&        f   t(        f      |      }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   r
   r'   r	   r   SimpleQueryr/   )r0   r1   msgquerys       r   get_str_queryr<   O   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%"
 %c4i(8+(E"FGOE*511
	4 r!   )__doc__r   collections.abcr   r   r   typingr   r   r   r	   r
   	multidictr   _quotersr   r   r   r   r9   QueryVariabler'   Queryr    r-   r/   r<    r!   r   <module>rE      s     7 7 ? ?  5Ce+,k8K#889#wsM)*HU3;M5N,OO	
  ,E%T	*M9:;(E%T	*K789&* * *c4i0@ *r!   