
     -Di                         d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZ d dlmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ  G d de      Z G d d      Z ed      ZdedefdZy)    )Iterable)	AnnotatedAnyBinaryIOCallableOptionalTypeVarcast)Doc)
CoreSchemaGetJsonSchemaHandlerJsonSchemaValue)URL)Address)FormData)Headers)QueryParams)State)
UploadFilec                   >    e Zd ZU dZee ed      f   ed<   eee	    ed      f   ed<   eee
    ed      f   ed<   ee ed      f   ed	<   eee	    ed
      f   ed<   dee ed      f   ddf fdZ	 d&dee
 ed      f   def fdZdee
 ed      f   ddf fdZd' fdZeded    deedef      fd       Zeded    dedefd       Zedededd fd       Zedee	ef   ddfd        Zed!ed"edefd#       Zed$ee   d"eegef   defd%       Z xZ S )(r   aA  
    A file uploaded in a request.

    Define it as a *path operation function* (or dependency) parameter.

    If you are using a regular `def` function, you can use the `upload_file.file`
    attribute to access the raw standard Python file (blocking, not async), useful and
    needed for non-async code.

    Read more about it in the
    [FastAPI docs for Request Files](https://fastapi.tiangolo.com/tutorial/request-files/).

    ## Example

    ```python
    from typing import Annotated

    from fastapi import FastAPI, File, UploadFile

    app = FastAPI()


    @app.post("/files/")
    async def create_file(file: Annotated[bytes, File()]):
        return {"file_size": len(file)}


    @app.post("/uploadfile/")
    async def create_upload_file(file: UploadFile):
        return {"filename": file.filename}
    ```
    z,The standard Python file object (non-async).filezThe original file name.filenamezThe size of the file in bytes.sizezThe headers of the request.headersz2The content type of the request, from the headers.content_typedatazA
                The bytes to write to the file.
                returnNc                 >   K   t         |   |       d{   S 7 w)z
        Write some bytes to the file.

        You normally wouldn't use this from a file you read in a request.

        To be awaitable, compatible with async, this is run in threadpool.
        N)superwrite)selfr   	__class__s     Y/var/www/html/backtest/python_venv/lib/python3.12/site-packages/fastapi/datastructures.pyr    zUploadFile.writeH   s     $ W]4((((   zL
                The number of bytes to read from the file.
                c                 >   K   t         |   |       d{   S 7 w)z|
        Read some bytes from the file.

        To be awaitable, compatible with async, this is run in threadpool.
        N)r   read)r!   r   r"   s     r#   r&   zUploadFile.read\   s       W\$''''r$   offsetzO
                The position in bytes to seek to in the file.
                c                 >   K   t         |   |       d{   S 7 w)z
        Move to a position in the file.

        Any next read or write will be done from that position.

        To be awaitable, compatible with async, this is run in threadpool.
        N)r   seek)r!   r'   r"   s     r#   r)   zUploadFile.seekn   s     $ W\&))))r$   c                 <   K   t         |           d{   S 7 w)zm
        Close the file.

        To be awaitable, compatible with async, this is run in threadpool.
        N)r   close)r!   r"   s    r#   r+   zUploadFile.close   s      W]_$$$s   cls.c              #   (   K   | j                    y wN)validate)r,   s    r#   __get_validators__zUploadFile.__get_validators__   s     lls   vc                 T    t        |t              st        dt        |             |S NzExpected UploadFile, received: )
isinstanceStarletteUploadFile
ValueErrortype)r,   r1   s     r#   r/   zUploadFile.validate   s)    !01>tAwiHII    _UploadFile__input_value_c                 p    t        |t              st        dt        |             t	        t
        |      S r3   )r4   r5   r6   r7   r
   r   )r,   r9   r:   s      r#   	_validatezUploadFile._validate   s3    -)<=>tM?R>STUUJ..r8   field_schemac                 ,    |j                  ddd       y Nstringbinary)r7   format)update)r,   r=   s     r#   __modify_schema__zUploadFile.__modify_schema__   s    XBCr8   core_schemahandlerc                     dddS r?    )r,   rE   rF   s      r#   __get_pydantic_json_schema__z'UploadFile.__get_pydantic_json_schema__   s     !H55r8   sourcec                 2    ddl m}  || j                        S )N   )"with_info_plain_validator_function)
_compat.v2rM   r<   )r,   rJ   rF   rM   s       r#   __get_pydantic_core_schema__z'UploadFile.__get_pydantic_core_schema__   s     	C1#--@@r8   ))r   N)!__name__
__module____qualname____doc__r   r   r   __annotations__r   strintr   bytesr    r&   r)   r+   classmethodr7   r   r   r   r0   r/   r<   dictrD   r   r   r   rI   rO   __classcell__)r"   s   @r#   r   r      sX   B :;	=  s+D'EEFF
HSM3'G#HH
IIw$A BBCCsOPP )
) 
): (
( 
($*
* 
*(% \ 2 xc@R7S   d<( S S  
 /c /c /l / / DT#s(^ D D D 6$6/C6	6 6
 A#YA)13%2C)DA	A Ar8   r   c                   8    e Zd ZdZdefdZdefdZdedefdZ	y)	DefaultPlaceholderz
    You shouldn't use this class directly.

    It's used internally to recognize when a default value has been overwritten, even
    if the overridden default value was truthy.
    valuec                     || _         y r.   r^   )r!   r^   s     r#   __init__zDefaultPlaceholder.__init__   s	    
r8   r   c                 ,    t        | j                        S r.   )boolr^   )r!   s    r#   __bool__zDefaultPlaceholder.__bool__   s    DJJr8   oc                 X    t        |t              xr |j                  | j                  k(  S r.   )r4   r]   r^   )r!   re   s     r#   __eq__zDefaultPlaceholder.__eq__   s"    !/0JQWW

5JJr8   N)
rQ   rR   rS   rT   r   ra   rc   rd   objectrg   rH   r8   r#   r]   r]      s5    c  $  K K4 Kr8   r]   DefaultTyper^   r   c                     t        |       S )z
    You shouldn't use this function directly.

    It's used internally to recognize when a default value has been overwritten, even
    if the overridden default value was truthy.
    )r]   r`   s    r#   Defaultrk      s     e$$r8   N)collections.abcr   typingr   r   r   r   r   r	   r
   annotated_docr   fastapi._compatr   r   r   starlette.datastructuresr   r   r   r   r   r   r   r5   r]   ri   rk   rH   r8   r#   <module>rq      sz    $    
 0 7 9 7 ? 3 FPA$ PAfK K$ m$%; %; %r8   