xL i] ddlmZddlZddlZddlZddlZddlmZddlm Z ejrddl m Z ddZ ddZddd Zddd Zdd Zdd Zdd ZGddZddZddZy)) annotationsN) getproxies) PrimitiveDataURLc2|dury|dury|yt|S)z Coerce a primitive data type into a string value. Note that we prefer JSON-style 'true'/'false' for boolean values here. TtrueFfalse)strvalues R/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/httpx/_utils.pyprimitive_value_to_strrs*  } %  u:ct}i}dD]*}|j|s||}d|vr|nd|||d<,|jddjdDcgc]}|j}}|D]e}|dk(ricS|sd|vrd||<t |r d|d |<-t |r d|d |d <B|j d k(r d|d |<^d|d |<g|Scc}w)z+Gets proxy information from the environment)httphttpsallz://zhttp://nor ,*Nzall://zall://[] localhostzall://*)rgetsplitstripis_ipv4_hostnameis_ipv6_hostnamelower) proxy_infomountsschemehostnamehostno_proxy_hostss rget_environment_proxiesr(s1J$&F* >>& !!&)H!X-WXJ3G fXS> "0:~~dB/G/M/Mc/RStdjjlSNS"4 s? I  #'x !(+.2z*+!(+04 !,-![0.2z*+/3 +,548 M;TsC$cHt|tr|j|S|SN isinstancer encoderencodings rto_bytesr0Os%/s%;5<< !FFrcHt|tr|S|j|Sr*)r,r decoder.s rto_strr3Ssuc*5F X0FFrcFt|tr|S|jSr*r+)r match_type_ofs rto_bytes_or_strr6Ws}c25F Frc8|d|dcxk(rdk(rnn|ddS|S)Nr"rrs runquoter;[s'(eBi63652;AEArcB |j}tj|j}|S#tt f$r\ |j }|jdtj}|j|Y|S#tt f$rYYywxYwwxYw)zs Given a file-like stream object, return its length in number of bytes without reading it into memory. rN) filenoosfstatst_sizeAttributeErrorOSErrortellseekSEEK_END)streamfdlengthoffsets rpeek_filelike_lengthrJ_s  ]]_"%% M G $  [[]F[[BKK0F KK  M (   s(/3BABBBBBcJeZdZdZd dZd dZed dZd dZd dZ ddZ y) URLPatterna A utility class currently used for making lookups against proxy keys... # Wildcard matching... >>> pattern = URLPattern("all://") >>> pattern.matches(httpx.URL("http://example.com")) True # Witch scheme matching... >>> pattern = URLPattern("https://") >>> pattern.matches(httpx.URL("https://example.com")) True >>> pattern.matches(httpx.URL("http://example.com")) False # With domain matching... >>> pattern = URLPattern("https://example.com") >>> pattern.matches(httpx.URL("https://example.com")) True >>> pattern.matches(httpx.URL("http://example.com")) False >>> pattern.matches(httpx.URL("https://other.com")) False # Wildcard scheme, with domain matching... >>> pattern = URLPattern("all://example.com") >>> pattern.matches(httpx.URL("https://example.com")) True >>> pattern.matches(httpx.URL("http://example.com")) True >>> pattern.matches(httpx.URL("https://other.com")) False # With port matching... >>> pattern = URLPattern("https://example.com:1234") >>> pattern.matches(httpx.URL("https://example.com:1234")) True >>> pattern.matches(httpx.URL("https://example.com")) False c8ddlm}|rd|vrtd|d|d||}||_|jdk(rdn |j|_|j d k(rdn |j |_|j |_|j r|j d k(rd|_y|j jd rAtj|j d d}tjd |d |_y|j jd rAtj|j dd}tjd|d |_ytj|j }tjd|d |_y)Nrr:zUProxy keys should use proper URL forms rather than plain scheme strings. Instead of "z", use "z://"rr rz*.z^.+\.$z^(.+\.)?^) _urlsr ValueErrorpatternr$r&port host_regex startswithreescapecompile)selfrTrurldomains r__init__zURLPattern.__init__sI s')&ixy>  'l JJ%/bSZZ ((c/Bsxx HH xx388s?:>DO XX  &YYsxx|,F jj6&);?DOYYsxx(F jj1VHA7DOrc|jr|j|jk7ry|jr2|j&|jj|jsy|j|j|jk7ryy)NFT)r$r&rVmatchrUr[others rmatcheszURLPattern.matchessd ;;4;;%,,6 II+OO))%**5 99 TYY%**%<rc|jdnd}t|j }t|j }|||fS)z The priority allows URLPattern instances to be sortable, so that we can match from most specific to least specific. rr)rUlenr&r$)r[ port_priority host_priorityscheme_prioritys rpriorityzURLPattern.prioritysA"YY2 TYY t{{++}o>>rc,t|jSr*)hashrT)r[s r__hash__zURLPattern.__hash__sDLL!!rc4|j|jkSr*)riras r__lt__zURLPattern.__lt__s}}u~~--rcXt|txr|j|jk(Sr*)r,rLrTras r__eq__zURLPattern.__eq__s!%,N1NNrN)rTr returnNone)rbrrqbool)rqztuple[int, int, int])rqint)rbrLrqrs)rb typing.Anyrqrs) __name__ __module__ __qualname____doc__r^rcpropertyrirlrnrpr:rrrLrLxs6'R8<  ? ?".OrrLcr tj|jddy#t$rYywxYwN/rFT) ipaddress IPv4Addressr Exceptionr%s rrr<hnnS1!45   '* 66cr tj|jddy#t$rYywxYwr|)r~ IPv6Addressrrrs rr r rr)rrrqr )rqzdict[str, str | None])zutf-8)r str | bytesr/r rqbytes)rrr/r rqr )rr r5 typing.AnyStrrqr)rr rqr )rFrurqz int | None)r%r rqrs) __future__rr~r>rXtypingurllib.requestr_typesr TYPE_CHECKINGrRrrr(r0r3r6r;rJrLrr r:rrrsg" %!  .bGGGB2jOjOZr