a c4Z@spddlZddlmZddlmZddlmZmZmZmZddl m Z ddl m Z Gdddej Zed Zejd d d ZGd ddZGdddeZGdddZGdddeZGdddejeefZGdddeejejfZGdddeeefZGdddZGdddeeejeeffZGdd d ejeefZGd!d"d"eZ Gd#d$d$Z!dS)%N)Sequence)shlex) SplitResult parse_qsl urlencodeurlsplit)run_in_threadpool)Scopec@seZdZUeed<eed<dS)AddresshostportN)__name__ __module__ __qualname__str__annotations__intrre/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/starlette/datastructures.pyr s r _KeyType_CovariantValueTypeT) covariantc@seZdZd.eejeejddddZe e dddZ e edd d Z e edd d Z e edd dZe edddZe edddZe ejdefdddZe ejdefdddZe ejdefdddZe ejedddZe edddZejddddZejddd d!Zejddd"d#Zejeejefdd$d%d&Zejed'd(d)Zedd*d+Zedd,d-Z dS)/URLN)urlscope componentsreturncKsN|dur|rJd|r"Jd|dd}|dd}|dd|d}|d d }d}|d D]\} } | d krf| d }qqf|dur|d||}n\|dur|}nN|\} } ddddd|} | | kr|d| |}n|d| d| |}|rD|d|7}n.|rD|r*Jdtdjfi|j}||_dS)Nz"Cannot set both "url" and "scope".z+Cannot set both "scope" and "**components".schemehttpserver root_pathrpath query_stringheadersshostlatin-1z://Pi)rhttpswswss:?z)Cannot set both "url" and "**components".)getdecoderreplacergeturl_url)selfrrrrr r"r#Z host_headerkeyvaluer r default_portrrr__init__s6       z URL.__init__rcCst|dst|j|_|jS)N _components)hasattrrr1r8r2rrrr?s  zURL.componentscCs|jjSN)rrr:rrrrEsz URL.schemecCs|jjSr;)rnetlocr:rrrr<Isz URL.netloccCs|jjSr;)rr"r:rrrr"MszURL.pathcCs|jjSr;)rqueryr:rrrr=Qsz URL.querycCs|jjSr;)rfragmentr:rrrr>Usz URL.fragmentcCs|jjSr;)rusernamer:rrrr?Ysz URL.usernamecCs|jjSr;)rpasswordr:rrrr@]sz URL.passwordcCs|jjSr;)rhostnamer:rrrrAasz URL.hostnamecCs|jjSr;)rr r:rrrr eszURL.portcCs |jdvS)N)r(r*)rr:rrr is_secureisz URL.is_secure)kwargsrc Ksd|vs d|vs d|vs d|vr|dd}|d|j}|d|j}|d|j}|dur|j}|d\}}}|ddkr|dd d }|}|dur|d|7}|dur|}|dur|d|7}|d|}||d <|jjfi|} | | S) Nr?r@rAr @]r+rr<) popr r?r@r< rpartitionrsplitr_replace __class__r0) r2rCrAr r?r@r<_Zuserpassrrrrr/ms8  z URL.replacecKsBtt|jdd}|dd|Dt|}|j|dS)NTkeep_blank_valuescSsi|]\}}t|t|qSrr.0r3r4rrr r$z,URL.include_query_params..r=) MultiDictrr=updateitemsr multi_itemsr/)r2rCparamsr=rrrinclude_query_paramss zURL.include_query_paramscKs"tdd|D}|j|dS)NcSs g|]\}}t|t|fqSrrPrQrrr r$z,URL.replace_query_params..rT)rrWr/)r2rCr=rrrreplace_query_paramsszURL.replace_query_params)keysrcCsPt|tr|g}tt|jdd}|D]}||dq&t|}|j|dS)NTrNrT) isinstancerrUrr=rHrrXr/)r2r]rYr3r=rrrremove_query_paramss  zURL.remove_query_paramsotherrcCst|t|kSr;rPr2rarrr__eq__sz URL.__eq__cCs|jSr;)r1r:rrr__str__sz URL.__str__cCs6t|}|jrt|jdd}|jjdt|dS)Nz********)r@())rr@r/rLr repr)r2rrrr__repr__sz URL.__repr__)rN)!r rrrtypingOptionalr Anyr6propertyrrrr<r"r=r>Unionr?r@rArr boolrBr/rZr\rr_rcrdrhrrrrrsN (! rc@sVeZdZdZd eeeddddZd eeeddddZejee fed d d Z dS)URLPathz A URL path string that may also hold an associated protocol and/or host. Used by the routing to return `url_path_for` matches. r)r"protocolr rcCs|dvs Jt||S)N)r websocketr)r__new__)clsr"rpr rrrrrs zURLPath.__new__NcCs||_||_dSr;)rpr )r2r"rpr rrrr6szURLPath.__init__)base_urlrcCstt|trt|}|jr.)r^rr whitespacewhitespace_split_itemslist)r2r4Zsplitterrrrr6s   zCommaSeparatedStrings.__init__r7cCs t|jSr;)lenrr:rrr__len__szCommaSeparatedStrings.__len__)indexrcCs |j|Sr;)r)r2rrrr __getitem__sz!CommaSeparatedStrings.__getitem__cCs t|jSr;)iterrr:rrr__iter__szCommaSeparatedStrings.__iter__cCs&|jj}dd|D}|d|dS)NcSsg|]}|qSrrrrrrr[r$z2CommaSeparatedStrings.__repr__..rerfr~r2rrWrrrrhszCommaSeparatedStrings.__repr__cCsddd|DS)N, css|]}t|VqdSr;)rgrrrr r$z0CommaSeparatedStrings.__str__..)joinr:rrrrdszCommaSeparatedStrings.__str__N)r rrrirmrrr6rrslicerkrIteratorrrhrdrrrrrs  rc@s4eZdZUejeefed<ejdej eefej ej eeffej ddddZ ej ejeddd Zejed d d Zejed d dZejeefd ddZejej eefd ddZeedddZej edddZejed ddZed ddZej edddZed ddZ dS) ImmutableMultiDict_dictz1ImmutableMultiDict[_KeyType, _CovariantValueType]NargsrCrcOst|dksJd|r |dng}|r@t|t|}|sJg}nt|drvttttf|}t|}nVt|drttj ttf|}t| }n(ttj tj tj tj f|}t|}dd|D|_||_dS)NToo many arguments.rrXrWcSsi|]\}}||qSrrrRkvrrrrS#r$z/ImmutableMultiDict.__init__..)rrrXr9ricastrrrMappingrWListTuplerkr_list)r2rrCr4rrrrr6s.      zImmutableMultiDict.__init__r3rcsfdd|jDS)Ncsg|]\}}|kr|qSrrrRitem_key item_valuer3rrr['r$z.ImmutableMultiDict.getlist..rr2r3rrrgetlist&szImmutableMultiDict.getlistr7cCs |jSr;)rr]r:rrrr])szImmutableMultiDict.keyscCs |jSr;)rvaluesr:rrrr,szImmutableMultiDict.valuescCs |jSr;)rrWr:rrrrW/szImmutableMultiDict.itemscCs t|jSr;rrr:rrrrX2szImmutableMultiDict.multi_itemscCs |j|Sr;rrrrrr5szImmutableMultiDict.__getitem__cCs ||jvSr;rrrrr __contains__8szImmutableMultiDict.__contains__cCs t|Sr;rr]r:rrrr;szImmutableMultiDict.__iter__cCs t|jSr;)rrr:rrrr>szImmutableMultiDict.__len__r`cCs$t||jsdSt|jt|jkSNF)r^rLsortedrrbrrrrcAs zImmutableMultiDict.__eq__cCs |jj}|}|d|dSNrerf)rLr rXrrrrrhFszImmutableMultiDict.__repr__)!r rrriDictrrrrmrIterablerrkr6rrKeysViewr] ValuesViewr ItemsViewrWrXrrnrrrrrrcrrhrrrrrs*   %rc@seZdZejejddddZejddddZdejejejdd d Zejd d d Z ejej dddZ dd ddZ dejejejdddZ ejej ddddZejejddddZejdejej ejejejffejddddZdS)rUNr3r4rcCs|||gdSr;)setlistr2r3r4rrr __setitem__MszMultiDict.__setitem__rcs"fdd|jD|_|j=dS)Ncs g|]\}}|kr||fqSrrrrrrr[Qr$z)MultiDict.__delitem__..)rrrrrr __delitem__PszMultiDict.__delitem__)r3defaultrcs$fdd|jD|_|j|S)Ncs g|]\}}|kr||fqSrrrrrrr[Ur$z!MultiDict.pop..)rrrHr2r3rrrrrHTsz MultiDict.popr7cs,|j\}fdd|jD|_|fS)Ncs g|]\}}|kr||fqSrrrrrrr[Zr$z%MultiDict.popitem..)rpopitemrr}rrrrXszMultiDict.popitemcs"fdd|jD}||S)Ncsg|]\}}|kr|qSrrrrrrr[^r$z%MultiDict.poplist..)rrH)r2r3rrrrpoplist]s zMultiDict.poplistcCs|j|jdSr;)rclearrr:rrrrbs zMultiDict.clearcCs*||vr"||j|<|j||f||Sr;)rrappendrrrr setdefaultfs zMultiDict.setdefault)r3rrcsP|s|dn:fdd|jD}|fdd|D|_|d|j<dS)Ncs g|]\}}|kr||fqSrrrrrrr[qr$z%MultiDict.setlist..csg|] }|fqSrr)rRr4rrrr[rr$rE)rHrr)r2r3rexisting_itemsrrrrms zMultiDict.setlistcCs|j||f||j|<dSr;)rrrrrrrruszMultiDict.appendrcs@t|i|fdd|jD}||_|jdS)Ncs$g|]\}}|vr||fqSr)r]rrzrrr[r$z$MultiDict.update..)rUrrXrrV)r2rrCrrrzrrVys zMultiDict.update)N)N)r rrrirkrrrHrrrrrrrrrmrrVrrrrrULs$rUcsneZdZdZejdejejejej ej fe e fej ddfdd Z e ddd Z e dd d ZZS) QueryParamsz! An immutable multidict. rNrcst|dksJd|r |dng}t|trLtjt|ddfi|n@t|trztjt|dddfi|ntj|i|dd|jD|_d d |j D|_ dS) NrrrTrNr&cSs g|]\}}t|t|fqSrrPrrrrr[r$z(QueryParams.__init__..cSsi|]\}}t|t|qSrrPrrrrrSr$z(QueryParams.__init__..) rr^rsuperr6rbytesr.rrrW)r2rrCr4rLrrr6s   zQueryParams.__init__r7cCs t|jSr;)rrr:rrrrdszQueryParams.__str__cCs |jj}t|}|d|dSr)rLr r)r2rr#rrrrhszQueryParams.__repr__)r rrrxrirmrrrrkrrr6rdrh __classcell__rrrrrsrc@seZdZdZddddejejeejedddddZ e ejedd d Z e e dd d Z edd ddZdeedddZeddddZddddZdS) UploadFilez@ An uploaded file included as part of the request data. N)sizefilenamer%ztyping.Optional[Headers])filerrr%rcCs"||_||_||_|pt|_dSr;)rrrHeadersr%)r2rrrr%rrrr6szUploadFile.__init__r7cCs|jddS)Nz content-type)r%r-r:rrr content_typeszUploadFile.content_typecCst|jdd}| S)N_rolledT)getattrr)r2Zrolled_to_diskrrr _in_memoryszUploadFile._in_memory)datarcsH|jdur|jt|7_|jr0|j|nt|jj|IdHdSr;)rrrrwriter)r2rrrrrs  zUploadFile.writerE)rrcs&|jr|j|St|jj|IdHSr;)rrreadr)r2rrrrrs zUploadFile.read)offsetrcs,|jr|j|nt|jj|IdHdSr;)rrseekr)r2rrrrrszUploadFile.seekcs(|jr|jnt|jjIdHdSr;)rrcloserr:rrrrs zUploadFile.close)rE)r rrrxriBinaryIOrjrrr6rlrrnrrrrrrrrrrrs&  rc s|eZdZdZejdejeejeeffej ej eejeefffejeefddfdd Z ddddZ Z S) FormDatazN An immutable multidict, containing both file uploads and text input. Nrcstj|i|dSr;)rr6)r2rrCrrrr6s zFormData.__init__r7cs.|D] \}}t|tr|IdHqdSr;)rXr^rrrrrrrs zFormData.close)r rrrxrirmrrrrrr6rrrrrrrs  rc@sPeZdZdZd"ejejeefejejej e e fejej eej fddddZ eejej e e fdddZejedd d Zejedd d Zejej eefdd dZeejedddZddddZeedddZej edddZejej dddZedddZej edddZedd d!ZdS)#rz3 An immutable, case-insensitive multidict. N)r%rawrrcCsg|_|durD|dusJd|dus.Jddd|D|_n>|durd|dus\Jd||_n|durt|d|_|d<dS)Nz$Cannot set both "headers" and "raw".z&Cannot set both "headers" and "scope".cSs(g|] \}}|d|dfqSr&)lowerencoderQrrrr[ sz$Headers.__init__..z"Cannot set both "raw" and "scope".r%)rrWr)r2r%rrrrrr6s zHeaders.__init__r7cCs t|jSr;rr:rrrrsz Headers.rawcCsdd|jDS)NcSsg|]\}}|dqSrr.rQrrrr[r$z Headers.keys..rr:rrrr]sz Headers.keyscCsdd|jDS)NcSsg|]\}}|dqSrrrQrrrr[ r$z"Headers.values..rr:rrrrszHeaders.valuescCsdd|jDS)NcSs$g|]\}}|d|dfqSrrrQrrrr[#sz!Headers.items..rr:rrrrW"sz Headers.itemsrcs"|dfdd|jDS)Nr&cs"g|]\}}|kr|dqSrrrget_header_keyrrr[*sz#Headers.getlist..rrrrrrrr(s zHeaders.getlistMutableHeaderscCst|jdddS)N)r)rrr:rrr mutablecopy0szHeaders.mutablecopycCs@|d}|jD]\}}||kr|dSqt|dS)Nr&)rrrr.KeyErrorr2r3rZ header_key header_valuerrrr3s zHeaders.__getitem__cCs0|d}|jD]\}}||krdSqdS)Nr&TFrrrrrr:s zHeaders.__contains__cCs t|Sr;rr:rrrrAszHeaders.__iter__cCs t|jSr;)rrr:rrrrDszHeaders.__len__r`cCs"t|tsdSt|jt|jkSr)r^rrrrbrrrrcGs zHeaders.__eq__cCsF|jj}t|}t|t|kr4|d|dS|d|jdS)Nrerfz(raw=)rLr dictrWrr)r2rZas_dictrrrrhLs  zHeaders.__repr__)NNN)r rrrxrirjrrrrrMutableMappingrkr6rlrr]rrWrrrrnrrrrrrcrhrrrrrs.  rc@seZdZeeddddZeddddZejeefddd d Zejeefddd d Z e ej ej e e fd ddZeeedddZejeefddddZeeddddZeddddZdS)rNrc Cs|d}|d}g}t|jD]\}\}}||kr&||q&t|ddD] }|j|=qV|r|d}||f|j|<n|j||fdS)zs Set the header `key` to `value`, removing any duplicate entries. Retains insertion order. r&rGNrrr enumeraterrreversed) r2r3r4set_key set_valueZ found_indexesidxrrrrrrUs   zMutableHeaders.__setitem__rcCsV|d}g}t|jD]\}\}}||kr||qt|D] }|j|=qDdS)z* Remove the header `key`. r&Nr)r2r3Zdel_keyZ pop_indexesrrrrrrrks  zMutableHeaders.__delitem__r`cCs,t|tjstd|jj|||SNzExpected a mapping but got )r^rir TypeErrorrLr rVrbrrr__ior__ys  zMutableHeaders.__ior__cCs4t|tjstd|jj|}|||Sr)r^rirrrLr rrV)r2ranewrrr__or__s   zMutableHeaders.__or__r7cCs|jSr;rr:rrrrszMutableHeaders.rawcCsZ|d}|d}t|jD]"\}\}}||kr"|dSq"|j||f|S)zo If the header `key` does not exist, then set it to `value`. Returns the header value. r&)rrrrr.r)r2r3r4rrrrrrrrrs zMutableHeaders.setdefaultcCs|D]\}}|||<qdSr;)rW)r2rar3valrrrrVszMutableHeaders.updatecCs,|d}|d}|j||fdS)zD Append a header, preserving any duplicate entries. r&N)rrrr)r2r3r4Z append_keyZ append_valuerrrrs zMutableHeaders.append)varyrcCs,|d}|dur d||g}||d<dS)Nrr)r-r)r2rexistingrrradd_vary_headers zMutableHeaders.add_vary_header)r rrrrrrirrrrlrrrrrrVrrrrrrrTs rcseZdZUdZejeejfed<dej ejeejfdfdd Z ejejdddd Z ejejd d d Z ejdd d dZ ZS)Statezm An object that can be used to store arbitrary state. Used for `request.state` and `app.state`. _stateN)statecs|dur i}td|dS)Nr)r __setattr__)r2rrrrr6szState.__init__rcCs||j|<dSr;rrrrrrszState.__setattr__rcCs<z |j|WSty6d}t||jj|Yn0dS)Nz!'{}' object has no attribute '{}')rrAttributeErrorformatrLr )r2r3messagerrr __getattr__s   zState.__getattr__cCs |j|=dSr;rrrrr __delattr__szState.__delattr__)N)r rrrxrirrrkrrjr6rrrrrrrrrs &r)"ricollections.abcrr urllib.parserrrrZstarlette.concurrencyrZstarlette.typesr NamedTupler TypeVarrrrrroryrrrrkrUrrrmrrrrrrrrs*     N<(7"WW