a c@sVddlZddlZddlZddlZddlZddlmZddlm Z m Z ddl m Z m Z mZmZmZmZmZmZmZmZmZddlmZddlmZmZddlmZddlmZm Z m!Z!m"Z"m#Z#dd l$m%Z%m&Z&m'Z'dd l(m)Z)m*Z*dd l+m,Z,dd l-m.Z.m/Z/m0Z0m1Z1m2Z2dd l3m4Z4ddl5m6Z6m7Z7ddl8m9Z9m:Z:ddl;mZ>ddl?m@Z@ddlAmBZBddlCmDZDddlEmFZFmGZGddlHmIZImJZJddlHmKZKddlHmLZLmMZMmNZNmOZOddlPmQZQddlRmSZSmTZTddlUmVZVddde eWeWeWe ddd ZXdddd!dddd!d"ee9e eee&e%feee&e%feWeWeWeWeWe d# d$d%ZYeeeZe feWe d&d'd(Z[ddeeFdddd!ddddf eee9ee\eeeGefee9eee&e%feee&e%feWeWeWeWee e eDgee e eGffd) d*d+Z]d5eee e eVgee e e ffd,d-d.Z^Gd/d0d0e>j_Z`Gd1d2d2e>jaZbGd3d4d4e>jcZddS)6N)AsyncExitStack)EnumIntEnum) AnyCallable CoroutineDictListOptionalSequenceSetTupleTypeUnion)params)DefaultDefaultPlaceholder) Dependant)get_body_field get_dependantget_parameterless_sub_dependantget_typed_return_annotationsolve_dependencies) DictIntStrAny SetIntStrjsonable_encoder)RequestValidationErrorWebSocketRequestValidationErrorDecoratedCallable)create_cloned_fieldcreate_response_fieldgenerate_unique_idget_value_or_defaultis_body_allowed_for_status_code) BaseModel) ErrorWrapperValidationError) ModelField Undefined)lenient_issubclass)routing)run_in_threadpool) HTTPException)Request) JSONResponseResponse) BaseRouteMatch)Mount) compile_pathget_namerequest_responsewebsocket_session)WS_1008_POLICY_VIOLATION)ASGIAppScope WebSocketF)exclude_defaults exclude_none)res exclude_unsetr=r>returncst|tr2t|jdd}|r |S|jddSt|trRfdd|DSt|trvfdd|DSt|rt |S|S)Nread_with_orm_modeT)by_aliasr@r=r>csg|]}t|dqSr@r=r>_prepare_response_content).0itemr=r>r@\/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/fastapi/routing.py Vsz-_prepare_response_content..c s"i|]\}}|t|dqSrDrF)rHkvrJrKrL `sz-_prepare_response_content..) isinstancer%getattrZ __config__dictlistitems dataclassesZ is_dataclassZasdict)r?r@r=r>rBrKrJrLrG@s*     rGT)fieldincludeexcluderCr@r=r> is_coroutine) rWresponse_contentrXrYrCr@r=r>rZrAc s|rg} t||||d}|r2|j|idd\} } nt|j|iddIdH\} } t| trd| | nt| trx| | | rt| |j t | ||||||dSt |SdS)NrE)response)loc)rXrYrCr@r=r>) rGvalidater,rQr&appendrTextendr'type_r) rWr[rXrYrCr@r=r>rZerrorsvalueZerrors_rKrKrLserialize_responsens:        rd) dependantvaluesrZrAcsH|jdusJd|r,|jfi|IdHSt|jfi|IdHSdS)N!dependant.call must be a function)callr,rerfrZrKrKrLrun_endpoint_functionsrj) re body_field status_coderesponse_classresponse_fieldresponse_model_includeresponse_model_excluderesponse_model_by_aliasresponse_model_exclude_unsetresponse_model_exclude_defaultsresponse_model_exclude_nonedependency_overrides_providerrAc sxjdusJdtjo.tjtjt|trB|jn|t t d fdd } | S)Nrg)requestrAc shzd}r҈rD|IdH}|jd}t|ts6J||jn|IdH}|rt}|j d}|sz| IdH}nFt j }||d<|dkr|}|dks|dr| IdH}|tkr|}n|}Wnt jy}z*tt|d|jfg|jd|WYd}~nPd}~0ty.Yn4ty`}ztdd d |WYd}~n d}~00t||d IdH} | \} } } } }| rt| |dnt| d IdH}t|tr|jdur| |_|Sd | i} r n| j}|dur||d<| jr | j|d<t|  d IdH}|fi|}t|jsNd|_|j j | j j|SdS)NZfastapi_astackz content-typeZ applicationjsonz+jsonbody)rxiz#There was an error parsing the body)rlZdetail)rvrerxruri backgroundrl) rWr[rXrYrCr@r=r>rZ)!formscopegetrQrpush_async_callbackcloserxr)headersrwemailmessageMessageget_content_maintypeget_content_subtypeendswithJSONDecodeErrorrr&posdocr- Exceptionrrjr0ryrlrdr$rawr`)rvrxstackZ body_bytesZ json_bodyZcontent_type_valuersubtypee solved_resultrfrbZbackground_tasksZ sub_response_Z raw_responseZ response_argsZcurrent_status_codecontentr\Zactual_response_classrkreruZ is_body_formrZrnrqrprsrtrrrorlrKrLapps            z get_request_handler..app) rhasyncioiscoroutinefunctionrQZ field_inforZFormrrcr.r0) rerkrlrmrnrorprqrrrsrtrurrKrrLget_request_handlers  .Rr)rerurAcstddfdd }|S)N) websocketrAcslt|dIdH}|\}}}}}|r@|jtdIdHt|jdusRJdjfi|IdHdS)N)rvreru)coderg)rrr8rrh)rrrfrbrZ_2Z_3rerurKrLrs zget_websocket_app..appr;)rerurrKrrLget_websocket_apps rcsZeZdZdddeedefeeeeddddZee e efdfdd Z Z S) APIWebSocketRouteN)nameru.)pathendpointrrurAcCs`||_||_|durt|n||_t|\|_|_|_t|j|jd|_ t t |j |d|_ dS)Nrrhr) rrr5rr4 path_regex path_formatparam_convertorsrrer7rr)selfrrrrurKrKrL__init__'szAPIWebSocketRoute.__init__r|rAcs*t|\}}|tjkr"||d<||fSNroutesupermatchesr2NONErr|matchZ child_scope __class__rKrLr;s zAPIWebSocketRoute.matches) __name__ __module__ __qualname__strrrr rr:r r2r __classcell__rKrKrrLr&s  rcseZdZedddddddddddddddddddeedddeedeedefee e e e e ee fe eeje ee eee ee e efeeeffe ee ee e eee efe ee e eefe e eefeeeeee eeefe ee e ee eeefe edgefefdddd Zeegeeeeffd d d Zeee efd fdd Z!Z"S)APIRouteNSuccessful ResponseTF)response_modelrltags dependenciessummary descriptionresponse_description responses deprecatedrmethods operation_idrorprqrrrsrtinclude_in_schemarmru callbacks openapi_extragenerate_unique_id_function.)rrrrlrrrrrrrrrrrorprqrrrsrtrrmrurrrrAc$Cs||_||_t|tr2t|}t|tr.d}n|}||_||_| |_ | |_ ||_ ||_ ||_ ||_||_||_||_||_||_||_||_||_||_|pg|_| pi|_| durt|n| |_t|\|_|_|_| durdg} dd| D|_ t|tr|j!}n|}|j p|||_"t|t#r2t$|}||_%|jrt&|sZJd|dd|j"}t'||jd|_(t)|j(|_*n d|_(d|_*|rt+||_,ng|_,|pt-.|jj/pd|_0|j01d d 2|_0i}|j3D]n\}} t| t4sJd | 5d }!|!rt&|s,Jd|dd|d |j"}t'||!d}"|"||<q|rd||_6ni|_6t7|s|Jdt8|j|jd|_9|j,dddD] }#|j9j,:d t;|#|jdqt<|j9|j"d|_=t>|?|_@dS)NGETcSsh|] }|qSrK)upper)rHmethodrKrKrL rzz$APIRoute.__init__..z Status code z must not have a response bodyZ Response_)rra rz%An additional response must be a dictmodelrzAn endpoint must be a callabler)dependsr)rer)ArrrQrrr*r0rrrrrrorprqrrrsrtrrmrurrrrrr5rr4rrrrrcZ unique_idrintrlr$r!rnr secure_cloned_response_fieldrTrinspectcleandoc__doc__rsplitstriprUrSr}response_fieldscallablerreinsertrrrkr6get_route_handlerr)$rrrrrlrrrrrrrrrrrorprqrrrsrtrrmrurrrreturn_annotationcurrent_generate_unique_idZ response_namerZadditional_status_coder\rrnrrKrKrLrCs"               zAPIRoute.__init__)rAcCs8t|j|j|j|j|j|j|j|j|j |j |j |j d S)N) rerkrlrmrnrorprqrrrsrtru) rrerkrlrmrrorprqrrrsrtru)rrKrKrLrszAPIRoute.get_route_handlerrcs*t|\}}|tjkr"||d<||fSrrrrrKrLrs zAPIRoute.matches)#rrrrr/r"rrrr rr rrr rDependsrboolr rrrr0rr1rr.rrr:r r2rrrKrKrrLrBsx    "rcs eZdZdddeeddddddeddddeedeee e ee fee e jeeeee eefeeeffee eee ejeeeeeeeee egefee egefeeeeegefddfddZd7eee eeeeeegefdd d Zeddddddd dddddddd d d deeddddeed eedefeeeee e ee fee e jeeeeeeee eefeeeffeeee eee efeeee eefee eefeeeeee eeefeeeeeee eeeeefe eegefefddddZ eddddddd dddddddd d d deedddeedeeeeee e ee fee e jeeeeeeee eefeeeffeeee eeeee eefee eefeeeeeeeeeee eeeeefeegefeegefdddZ!d8eedefeeddddZ"d9eeeeegefdddZ#d:ee edfeegefdddZ$dddeeddddeed deee e ee fee e jeeeee eefeeeffee eeeeeegefdd d d!Z%eddddddd ddddddd d d deedddeed"eeeeee e ee fee e jeeeeeeee eefeeeffeeeeee eefee eefeeeeeeeeeee eeeeefeegefeegefd#d$d%Z&eddddddd ddddddd d d deedddeed"eeeeee e ee fee e jeeeeeeee eefeeeffeeeeee eefee eefeeeeeeeeeee eeeeefeegefeegefd#d&d'Z'eddddddd ddddddd d d deedddeed"eeeeee e ee fee e jeeeeeeee eefeeeffeeeeee eefee eefeeeeeeeeeee eeeeefeegefeegefd#d(d)Z(eddddddd ddddddd d d deedddeed"eeeeee e ee fee e jeeeeeeee eefeeeffeeeeee eefee eefeeeeeeeeeee eeeeefeegefeegefd#d*d+Z)eddddddd ddddddd d d deedddeed"eeeeee e ee fee e jeeeeeeee eefeeeffeeeeee eefee eefeeeeeeeeeee eeeeefeegefeegefd#d,d-Z*eddddddd ddddddd d d deedddeed"eeeeee e ee fee e jeeeeeeee eefeeeffeeeeee eefee eefeeeeeeeeeee eeeeefeegefeegefd#d.d/Z+eddddddd ddddddd d d deedddeed"eeeeee e ee fee e jeeeeeeee eefeeeffeeeeee eefee eefeeeeeeeeeee eeeeefeegefeegefd#d0d1Z,eddddddd ddddddd d d deedddeed"eeeeee e ee fee e jeeeeeeee eefeeeffeeeeee eefee eefeeeeeeeeeee eeeeefeegefeegefd#d2d3Z-eeegefd4d5d6Z.Z/S); APIRouterrNT)prefixrrdefault_response_classrrroutesredirect_slashesdefaultru route_class on_startup on_shutdownrrr)rrrrrrrrrrurrrrrrrAcstj||| | | d|r>|ds,Jd|dr>Jd||_|pJg|_t|pVgp\g|_||_||_ |pri|_ |p|g|_ | |_ | |_ ||_||_dS)N)rrrrr/!A path prefix must start with '/'FA path prefix must not end with '/', as the routes will start with '/')rr startswithrrrrTrrrrrrurrr)rrrrrrrrrrrurrrrrrrrKrLrs2   zAPIRouter.__init__)rrrrrAcs ttdfdd }|S)NfuncrAcsj|d|S)N)rrr) add_routerrrrrrrKrL decoratorsz"APIRouter.route..decoratorr)rrrrrrrKrrLr s zAPIRouter.routerFrrlrrrrrrrrrrorprqrrrsrtrrmrroute_class_overriderrr.)rrrrlrrrrrrrrrrorprqrrrsrtrrmrrrrrrAc#Cs|p|j}| pi} i|j| }t||j}|j}|rD|||j}|r\|||j} |rt| |t||j }!||j ||||||||| || p|j | | |||||||o|j |||j | ||!d}"|j|"dS)N)rrrlrrrrrrrrrrorprqrrrsrtrrmrrurrr)rrr#rrcopyr`rrrrrrrurr_)#rrrrrlrrrrrrrrrrorprqrrrsrtrrmrrrrrrcombined_responsesZcurrent_response_class current_tagscurrent_dependenciescurrent_callbacksrrrKrKrL add_api_route s^"       zAPIRouter.add_api_routerrlrrrrrrrrrrorprqrrrsrtrrmrrrr)rrrlrrrrrrrrrrorprqrrrsrtrrmrrrrrAcsHttd fdd }|S)Nrcs@j |    d|S)Nr)rrrrrrrrrrrrrrmrrrqrprsrtrrrorrrlrrrKrLrs8z&APIRouter.api_route..decoratorr)rrrrlrrrrrrrrrrorprqrrrsrtrrmrrrrrrKrrL api_routersDzAPIRouter.api_route)rrrrAcCs(t|j||||jd}|j|dS)N)rrru)rrrurr_)rrrrrrKrKrLadd_api_websocket_routesz!APIRouter.add_api_websocket_route)rrrAcsttdfdd }|S)Nrcsj|d|SNr)rrrrrrKrLrsz&APIRouter.websocket..decoratorrrrrrrKrrLrszAPIRouter.websocketcsttdfdd }|S)Nrcsj|d|Sr)add_websocket_routerrrKrLrsz,APIRouter.websocket_route..decoratorrrrKrrLwebsocket_routeszAPIRouter.websocket_route) rrrrrrrrr) routerrrrrrrrrrrAc Cs|r*|dsJd|drhJdn>|jD]6} t| d} t| dd} | dur0| s0td| dq0|durti}|jD]}t|tri||j}t|j |j ||j }g}|r| ||j r| |j g}|r| ||j r| |j g}|r | ||jr| |jt|j|j| |j}|j||j|j|j|j|||j|j|j||jpn|pn|j|j|j|j|j|j|j|j|j |j!o|j!o| ||j"t#|||j$|d qzt|t%j&rt'|jpg}|j(||j|j||j!|j"d qzt|t)r$|j*||j|j|j"d qzt|t%j+rz|j,||j|j|j"d qz|j-D]}|.d |qR|j/D]}|.d |qldS)Nrrrrrunknownz6Prefix and path cannot be both empty (path operation: )r)rrrrZstartupshutdown)0rrrrRrrQrrr#rmrr`rrrrrrrrrlrrrrrrrorprqrrrsrtrrtyperr+RouterTrrrWebSocketRouterradd_event_handlerr)rrrrrrrrrrrrrrrrZuse_response_classrrrrrhandlerrKrKrLinclude_routers                 zAPIRouter.include_router)rrlrrrrrrrrrorprqrrrsrtrrmrrrr)rrrlrrrrrrrrrorprqrrrsrtrrmrrrrrAcCs<|j||||||||| | dg| | | ||||||||||dS)NrrrrlrrrrrrrrrrorprqrrrsrtrrmrrrrrrrrrlrrrrrrrrrorprqrrrsrtrrmrrrrrKrKrLr}>s4z APIRouter.getcCs<|j||||||||| | dg| | | ||||||||||dS)NPUTr rrrKrKrLputvs4z APIRouter.putcCs<|j||||||||| | dg| | | ||||||||||dS)NPOSTr rrrKrKrLposts4zAPIRouter.postcCs<|j||||||||| | dg| | | ||||||||||dS)NDELETEr rrrKrKrLdeletes4zAPIRouter.deletecCs<|j||||||||| | dg| | | ||||||||||dS)NOPTIONSr rrrKrKrLoptionss4zAPIRouter.optionscCs<|j||||||||| | dg| | | ||||||||||dS)NHEADr rrrKrKrLheadVs4zAPIRouter.headcCs<|j||||||||| | dg| | | ||||||||||dS)NPATCHr rrrKrKrLpatchs4zAPIRouter.patchcCs<|j||||||||| | dg| | | ||||||||||dS)NTRACEr rrrKrKrLtraces4zAPIRouter.trace) event_typerAcsttdfdd }|S)Nrcs||S)N)r rrrrKrLrs z%APIRouter.on_event..decoratorr)rrrrKrrLon_eventszAPIRouter.on_event)NNT)N)N)N)0rrrrr/rr"rr r rrr rrrr0rrrr1r+rr9rrrrr rrrrrrrrr r}rrrrrrrr rrKrKrrLrs    1       V     ?        u    <    <    <    <    <    <    <    : r)N)errV email.messagerrrw contextlibrenumrrtypingrrrrr r r r r rrZfastapirZfastapi.datastructuresrrZfastapi.dependencies.modelsrZfastapi.dependencies.utilsrrrrrZfastapi.encodersrrrZfastapi.exceptionsrrZ fastapi.typesrZ fastapi.utilsr r!r"r#r$Zpydanticr%Zpydantic.error_wrappersr&r'Zpydantic.fieldsr(r)Zpydantic.utilsr*Z starletter+Zstarlette.concurrencyr,Zstarlette.exceptionsr-Zstarlette.requestsr.Zstarlette.responsesr/r0Zstarlette.routingr1r2r3r4r5r6r7Zstarlette.statusr8Zstarlette.typesr9r:Zstarlette.websocketsr<rrGrdrrjrrrrrrrZRouterrrKrKrKrLs 4             0 .  l