U
    ~fh                     @  s
  U d dl mZ d dlZd dlZd dlmZmZ d dlmZ d dl	m
Z
 d dlmZ ejZejZejZdZdZd	Ze
Zd
ZdZeedZded< eedZded< d"ddddddddZddddddZd#ddddddddZddddddZddddd d!Z dS )$    )annotationsN)AnyOptional)	ASCENDING)MAX_MESSAGE_SIZE)InvalidOperation       
i  i <   )Zfiles_idnzdict[str, Any]_C_INDEX)filenameZ
uploadDate_F_INDEXFstrzOptional[bool]r   )
field_name	docstring	read_onlyclosed_onlyreturnc                   s   d| drd dddd fdd}dddd	fd
d}|rX|d7 }n rhd|d}|s~ s~t|||dS t||dS )Create a GridIn property. DEPRECATED,GridIn property '2' is deprecated and will be removed in PyMongo 5.0r   selfr   c                   sN   rt jdtd  r*| js*td dkr@| jdS | jd S N   
stacklevelcategoryz can only get %r on a closed filelengthr   warningswarnDeprecationWarning_closedAttributeError_filegetr   r   r   warn_str ;/tmp/pip-unpacked-wheel-36gvocj8/gridfs/grid_file_shared.pygetter/   s    
z#_a_grid_in_property.<locals>.getterr   valuer   c                   s0   rt jdtd | jr"td|| j < d S )Nr   r   zAsyncGridIn does not support __setattr__ after being closed(). Set the attribute before closing the file or use AsyncGridIn.set() instead)r#   r$   r%   r&   r   r(   r   r1   r   r,   r-   r.   setter9   s    z#_a_grid_in_property.<locals>.setter

This attribute is read-only.{}

{}UThis attribute is read-only and can only be read after :meth:`close` has been called.doc
startswithformatpropertyr   r   r   r   r/   r4   r-   r+   r.   _a_grid_in_property!   s     


	
r?   )r   r   r   c                   s(   ddd fdd}|d7 }t ||dS )Create a GridOut property.r   r   c                   s6   | j std   dkr(| j  dS | j  d S )Nz=You must call GridOut.open() before accessing the %s propertyr!   r   )r(   r   r)   r*   r   r-   r.   a_getterT   s    z&_a_grid_out_property.<locals>.a_getterr5   r8   )r=   )r   r   rB   r-   rA   r.   _a_grid_out_propertyQ   s    
rC   c                   s   d| drd dddd fdd}dddd	fd
d}|rX|d7 }n rhd|d}|s~ s~t|||dS t||dS )r   r   r   r   r   r   r   c                   sN   rt jdtd  r*| js*td dkr@| jdS | jd S r   r"   r*   r+   r-   r.   r/   o   s    
z!_grid_in_property.<locals>.getterr0   c                   sJ   rt jdtd | jr<| jjd| jd id |ii || j < d S )Nr   r   Z_idz$set)r#   r$   r%   r&   Z_collfilesZ
update_oner(   r2   r3   r-   r.   r4   y   s
    "z!_grid_in_property.<locals>.setterr5   r6   r7   r8   r:   r>   r-   r+   r.   _grid_in_propertyb   s     



rE   c                   sD   d| drd  dddd fdd}|d	7 }t||d
S )r@   r   r   zGridOut property 'r   r   r   c                   s@   rt jdtd |    dkr2| j dS | j d S )Nr   r   r!   r   )r#   r$   r%   openr(   r)   r*   r3   r-   r.   r/      s    z"_grid_out_property.<locals>.getterr5   r8   )r;   r=   )r   r   r/   r-   r3   r.   _grid_out_property   s    


rG   )entitykwargsr   c                 K  s"   | j jdd}| jf d|i|S )z;Clear the given database/collection object's type registry.N)Ztype_registrycodec_options)rJ   Zwith_options)rH   rI   Z	codecoptsr-   r-   r.   _clear_entity_type_registry   s    rK   )FF)FF)!
__future__r   osr#   typingr   r   Zpymongor   Zpymongo.commonr   Zpymongo.errorsr   SEEK_SETZ	_SEEK_SETSEEK_CURZ	_SEEK_CURSEEK_ENDZ	_SEEK_ENDZEMPTYZNEWLNZDEFAULT_CHUNK_SIZEZ_UPLOAD_BUFFER_SIZEZ_UPLOAD_BUFFER_CHUNKSZ_CHUNK_OVERHEADr   __annotations__r   r?   rC   rE   rG   rK   r-   r-   r-   r.   <module>   s6      0  -