
    FCfU                       d Z ddlmZ ddlZddlmZmZmZmZm	Z	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mZ dd	lmZmZmZ dd
lmZmZmZ ddlmZ erddl m!Z! ee
ee"ee"ee#e"ee"ef   f   f   f      ee"ef   f   Z$ee"e$f   Z% G d de"ejL                        Z' G d dee         Z( G d d      Z) G d d      Z* G d dee         Z+ G d d      Z, G d de,      Z- G d de,      Z. G d d      Z/ G d d       Z0y)!zOperation class definitions.    )annotationsN)TYPE_CHECKINGAnyGenericMappingOptionalSequenceTupleUnion)RawBSONDocument)helpers)validate_collation_or_none)validate_is_mappingvalidate_list)_gen_index_name_index_document_index_list)_CollationIn_DocumentType	_Pipeline)validate_boolean)_Bulkc                  |    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZy)_OpabortTransaction	aggregatecommitTransactioncountcreatecreateIndexescreateSearchIndexesdeletedistinctdropdropDatabasedropIndexesdropSearchIndexesendSessionsfindAndModifyfindinsertlistCollectionslistIndexeslistSearchIndexeslistDatabasesupdateupdateIndexupdateSearchIndexrenamegetMorekillCursorstestOperationN)__name__
__module____qualname__ABORT	AGGREGATECOMMITCOUNTCREATECREATE_INDEXESCREATE_SEARCH_INDEXESDELETEDISTINCTDROPDROP_DATABASEDROP_INDEXESDROP_SEARCH_INDEXESEND_SESSIONSFIND_AND_MODIFYFINDINSERTLIST_COLLECTIONSLIST_INDEXESLIST_SEARCH_INDEXLIST_DATABASESUPDATEUPDATE_INDEXUPDATE_SEARCH_INDEXRENAMEGETMOREKILL_CURSORSTEST     R/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/pymongo/operations.pyr   r   0   s    EI FEF$N1FHD"M L- L%ODF( L+$NF L-FG LDrW   r   c                  <    e Zd ZdZdZd	dZd
dZddZddZddZ	y)	InsertOnez#Represents an insert_one operation._docc                    || _         y)zCreate an InsertOne instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :param document: The document to insert. If the document is missing an
            _id field one will be added.
        Nr[   )selfdocuments     rX   __init__zInsertOne.__init__T   s     	rW   c                :    |j                  | j                         y)3Add this operation to the _Bulk instance `bulkobj`.N)
add_insertr\   r^   bulkobjs     rX   _add_to_bulkzInsertOne._add_to_bulk^   s    499%rW   c                "    d| j                   dS )Nz
InsertOne()r[   r^   s    rX   __repr__zInsertOne.__repr__b   s    DII=**rW   c                n    t        |      t        |       k(  r|j                  | j                  k(  S t        S N)typer\   NotImplementedr^   others     rX   __eq__zInsertOne.__eq__e   s+    ;$t*$::**rW   c                    | |k(   S rl   rV   ro   s     rX   __ne__zInsertOne.__ne__j       5=  rW   N)r_   r   returnNonere   r   ru   rv   ru   strrp   r   ru   bool
r7   r8   r9   __doc__	__slots__r`   rf   rj   rq   rs   rV   rW   rX   rZ   rZ   O   s#    -I&+
!rW   rZ   c                  P    e Zd ZdZdZ	 	 d		 	 	 	 	 	 	 d
dZddZddZddZddZ	y)	DeleteOnez"Represents a delete_one operation._filter
_collation_hintNc                    |t        d|       |+t        |t              st        j                  |      | _        n|| _        || _        || _        y)a  Create a DeleteOne instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :param filter: A query that matches the document to delete.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.4 and above.

        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nfilterr   
isinstancery   r   r   r   r   r   r^   r   	collationhints       rX   r`   zDeleteOne.__init__s   K    2 &1JtS$9;B;R;RSW;XDJDJ#rW   c                |    |j                  | j                  dt        | j                        | j                         y)rb      r   r   N
add_deleter   r   r   r   rd   s     rX   rf   zDeleteOne._add_to_bulk   2    LL0A	 	 	
rW   c                V    d| j                   d| j                  d| j                  dS )Nz
DeleteOne(, rh   r   ri   s    rX   rj   zDeleteOne.__repr__   s,    DLL+2doo-@4::.PQRRrW   c                    t        |      t        |       k(  rG|j                  |j                  |j                  f| j                  | j                  | j                  fk(  S t        S rl   rm   r   r   r   rn   ro   s     rX   rq   zDeleteOne.__eq__   W    ;$t*$MM5#3#3U[[A

F  
 rW   c                    | |k(   S rl   rV   ro   s     rX   rs   zDeleteOne.__ne__   rt   rW   NNr   Mapping[str, Any]r   Optional[_CollationIn]r   Optional[_IndexKeyHint]ru   rv   rw   rx   rz   r|   rV   rW   rX   r   r   n   sS    ,2I
 -1(,	 $! $ * $ &	 $
 
 $D
S!rW   r   c                  P    e Zd ZdZdZ	 	 d		 	 	 	 	 	 	 d
dZddZddZddZddZ	y)
DeleteManyz#Represents a delete_many operation.r   Nc                    |t        d|       |+t        |t              st        j                  |      | _        n|| _        || _        || _        y)a  Create a DeleteMany instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :param filter: A query that matches the documents to delete.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.4 and above.

        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nr   r   r   s       rX   r`   zDeleteMany.__init__   r   rW   c                |    |j                  | j                  dt        | j                        | j                         y)rb   r   r   Nr   rd   s     rX   rf   zDeleteMany._add_to_bulk   r   rW   c                V    d| j                   d| j                  d| j                  dS )NzDeleteMany(r   rh   r   ri   s    rX   rj   zDeleteMany.__repr__   s,    T\\,Bt.ADJJ>QRSSrW   c                    t        |      t        |       k(  rG|j                  |j                  |j                  f| j                  | j                  | j                  fk(  S t        S rl   r   ro   s     rX   rq   zDeleteMany.__eq__   r   rW   c                    | |k(   S rl   rV   ro   s     rX   rs   zDeleteMany.__ne__   rt   rW   r   r   rw   rx   rz   r|   rV   rW   rX   r   r      sS    -2I
 -1(,	 $! $ * $ &	 $
 
 $D
T!rW   r   c                  Z    e Zd ZdZdZ	 	 	 d		 	 	 	 	 	 	 	 	 	 	 d
dZddZddZddZddZ	y)
ReplaceOnez#Represents a replace_one operation.)r   r\   _upsertr   r   Nc                    |t        d|       |t        d|       |+t        |t              st	        j
                  |      | _        n|| _        || _        || _        || _	        || _
        y)a  Create a ReplaceOne instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :param filter: A query that matches the document to replace.
        :param replacement: The new document.
        :param upsert: If ``True``, perform an insert if no documents
            match the filter.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.

        .. versionchanged:: 3.11
           Added the ``hint`` option.
        .. versionchanged:: 3.5
           Added the ``collation`` option.
        Nr   upsert)r   r   r   ry   r   r   r   r   r\   r   r   )r^   r   replacementr   r   r   s         rX   r`   zReplaceOne.__init__   si    < &1Xv.JtS$9;B;R;RSW;XDJDJ	#rW   c                    |j                  | j                  | j                  | j                  t	        | j
                        | j                         y)rb   r   N)add_replacer   r\   r   r   r   r   rd   s     rX   rf   zReplaceOne._add_to_bulk  s=    LLIILL0A 	 	
rW   c                "   t        |      t        |       k(  rs|j                  |j                  |j                  |j                  |j
                  f| j                  | j                  | j                  | j                  |j
                  fk(  S t        S rl   )rm   r   r\   r   r   r   rn   ro   s     rX   rq   zReplaceOne.__eq__(  sx    ;$t*$

   		  rW   c                    | |k(   S rl   rV   ro   s     rX   rs   zReplaceOne.__ne__9  rt   rW   c                    dj                  | j                  j                  | j                  | j                  | j
                  | j                  | j                        S )Nz {}({!r}, {!r}, {!r}, {!r}, {!r}))format	__class__r7   r   r\   r   r   r   ri   s    rX   rj   zReplaceOne.__repr__<  sE    188NN##LLIILLOOJJ
 	
rW   )FNN)r   r   r   z%Union[_DocumentType, RawBSONDocument]r   r{   r   r   r   r   ru   rv   rw   rz   rx   )
r7   r8   r9   r}   r~   r`   rf   rq   rs   rj   rV   rW   rX   r   r      si    -EI ,0(,)$!)$ ;)$ 	)$
 *)$ &)$ 
)$V
"!
rW   r   c                  D    e Zd ZdZdZ	 	 	 	 	 	 	 	 	 	 	 	 ddZddZd	dZy)
	_UpdateOpz)Private base class for update operations.)r   r\   r   r   _array_filtersr   c                   |t        d|       |t        d|       |t        d|       |+t        |t              st        j                  |      | _        n|| _        || _        || _	        || _
        || _        || _        y )Nr   r   array_filters)r   r   r   r   ry   r   r   r   r   r\   r   r   r   )r^   r   docr   r   r   r   s          rX   r`   z_UpdateOp.__init__L  s     &1Xv.$/=9JtS$9;B;R;RSW;XDJDJ	#+rW   c                J   t        |t        |             r|j                  |j                  |j                  |j
                  |j                  |j                  f| j                  | j                  | j                  | j
                  | j                  | j                  fk(  S t        S rl   )	r   rm   r   r\   r   r   r   r   rn   ro   s     rX   rq   z_UpdateOp.__eq__f  s    eT$Z(

  $$ 		##

  rW   c           	         dj                  | j                  j                  | j                  | j                  | j
                  | j                  | j                  | j                        S )Nz&{}({!r}, {!r}, {!r}, {!r}, {!r}, {!r}))	r   r   r7   r   r\   r   r   r   r   ri   s    rX   rj   z_UpdateOp.__repr__y  sN    7>>NN##LLIILLOOJJ
 	
rW   N)r   r   r   #Union[Mapping[str, Any], _Pipeline]r   r{   r   r   r   !Optional[list[Mapping[str, Any]]]r   r   )rp   objectru   r{   rx   )r7   r8   r9   r}   r~   r`   rq   rj   rV   rW   rX   r   r   G  sS    3WI,!, 1, 	,
 *, 9, &,4&	
rW   r   c                  T     e Zd ZdZdZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZddZ xZS )	UpdateOnez#Represents an update_one operation.rV   c                .    t         |   ||||||       y)a  Represents an update_one operation.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :param filter: A query that matches the document to update.
        :param update: The modifications to apply.
        :param upsert: If ``True``, perform an insert if no documents
            match the filter.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param array_filters: A list of filters specifying which
            array elements an update should apply.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.

        .. versionchanged:: 3.11
           Added the `hint` option.
        .. versionchanged:: 3.9
           Added the ability to accept a pipeline as the `update`.
        .. versionchanged:: 3.6
           Added the `array_filters` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nsuperr`   r^   r   r0   r   r   r   r   r   s          rX   r`   zUpdateOne.__init__      J 	M4PrW   c           	         |j                  | j                  | j                  d| j                  t	        | j
                        | j                  | j                         y)rb   Fr   r   r   N
add_updater   r\   r   r   r   r   r   rd   s     rX   rf   zUpdateOne._add_to_bulk  sI    LLIILL0A-- 	 	
rW   FNNNr   r   r0   r   r   r{   r   r   r   r   r   r   ru   rv   rw   r7   r8   r9   r}   r~   r`   rf   __classcell__r   s   @rX   r   r     sp    -I ,0;?(,%Q!%Q 4%Q 	%Q
 *%Q 9%Q &%Q 
%QN

rW   r   c                  T     e Zd ZdZdZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 d fdZddZ xZS )
UpdateManyz$Represents an update_many operation.rV   c                .    t         |   ||||||       y)a  Create an UpdateMany instance.

        For use with :meth:`~pymongo.collection.Collection.bulk_write`.

        :param filter: A query that matches the documents to update.
        :param update: The modifications to apply.
        :param upsert: If ``True``, perform an insert if no documents
            match the filter.
        :param collation: An instance of
            :class:`~pymongo.collation.Collation`.
        :param array_filters: A list of filters specifying which
            array elements an update should apply.
        :param hint: An index to use to support the query
            predicate specified either by its string name, or in the same
            format as passed to
            :meth:`~pymongo.collection.Collection.create_index` (e.g.
            ``[('field', ASCENDING)]``). This option is only supported on
            MongoDB 4.2 and above.

        .. versionchanged:: 3.11
           Added the `hint` option.
        .. versionchanged:: 3.9
           Added the ability to accept a pipeline as the `update`.
        .. versionchanged:: 3.6
           Added the `array_filters` option.
        .. versionchanged:: 3.5
           Added the `collation` option.
        Nr   r   s          rX   r`   zUpdateMany.__init__  r   rW   c           	         |j                  | j                  | j                  d| j                  t	        | j
                        | j                  | j                         y)rb   Tr   Nr   rd   s     rX   rf   zUpdateMany._add_to_bulk  sI    LLIILL0A-- 	 	
rW   r   r   rw   r   r   s   @rX   r   r     sp    .I ,0;?(,%Q!%Q 4%Q 	%Q
 *%Q 9%Q &%Q 
%QN

rW   r   c                  .    e Zd ZdZdZddZedd       Zy)
IndexModelzRepresents an index to create.
__documentc                    t        |      }|j                  d      t        |      |d<   t        |      |d<   t	        |j                  dd            }|| _        ||| j                  d<   yy)a  Create an Index instance.

        For use with :meth:`~pymongo.collection.Collection.create_indexes`.

        Takes either a single key or a list containing (key, direction) pairs
        or keys.  If no direction is given, :data:`~pymongo.ASCENDING` will
        be assumed.
        The key(s) must be an instance of :class:`str`, and the direction(s) must
        be one of (:data:`~pymongo.ASCENDING`, :data:`~pymongo.DESCENDING`,
        :data:`~pymongo.GEO2D`, :data:`~pymongo.GEOSPHERE`,
        :data:`~pymongo.HASHED`, :data:`~pymongo.TEXT`).

        Valid options include, but are not limited to:

          - `name`: custom name to use for this index - if none is
            given, a name will be generated.
          - `unique`: if ``True``, creates a uniqueness constraint on the index.
          - `background`: if ``True``, this index should be created in the
            background.
          - `sparse`: if ``True``, omit from the index any documents that lack
            the indexed field.
          - `bucketSize`: for use with geoHaystack indexes.
            Number of documents to group together within a certain proximity
            to a given longitude and latitude.
          - `min`: minimum value for keys in a :data:`~pymongo.GEO2D`
            index.
          - `max`: maximum value for keys in a :data:`~pymongo.GEO2D`
            index.
          - `expireAfterSeconds`: <int> Used to create an expiring (TTL)
            collection. MongoDB will automatically delete documents from
            this collection after <int> seconds. The indexed field must
            be a UTC datetime or the data will not expire.
          - `partialFilterExpression`: A document that specifies a filter for
            a partial index.
          - `collation`: An instance of :class:`~pymongo.collation.Collation`
            that specifies the collation to use.
          - `wildcardProjection`: Allows users to include or exclude specific
            field paths from a `wildcard index`_ using the { "$**" : 1} key
            pattern. Requires MongoDB >= 4.2.
          - `hidden`: if ``True``, this index will be hidden from the query
            planner and will not be evaluated as part of query plan
            selection. Requires MongoDB >= 4.4.

        See the MongoDB documentation for a full list of supported options by
        server version.

        :param keys: a single key or a list containing (key, direction) pairs
             or keys specifying the index to create.
        :param kwargs: any additional index creation
            options (see the above list) should be passed as keyword
            arguments.

        .. versionchanged:: 3.11
           Added the ``hidden`` option.
        .. versionchanged:: 3.2
           Added the ``partialFilterExpression`` option to support partial
           indexes.

        .. _wildcard index: https://mongodb.com/docs/master/core/index-wildcard/
        nameNkeyr   )r   getr   r   r   pop_IndexModel__document)r^   keyskwargsr   s       rX   r`   zIndexModel.__init__  so    z 4 ::f%,T2F6N'-u.vzz+t/LM	  +4DOOK( !rW   c                    | j                   S )zUAn index document suitable for passing to the createIndexes
        command.
        )r   ri   s    rX   r_   zIndexModel.documentB  s    
 rW   N)r   _IndexKeyHintr   r   ru   rv   )ru   zdict[str, Any]r7   r8   r9   r}   r~   r`   propertyr_   rV   rW   rX   r   r     s%    (ID5L  rW   r   c                  F    e Zd ZdZdZ	 	 d	 	 	 	 	 	 	 	 	 ddZedd       Zy)	SearchIndexModelz$Represents a search index to create.r   Nc                    i | _         ||| j                   d<   || j                   d<   ||| j                   d<   | j                   j                  |       y)a  Create a Search Index instance.

        For use with :meth:`~pymongo.collection.Collection.create_search_index` and :meth:`~pymongo.collection.Collection.create_search_indexes`.

        :param definition: The definition for this index.
        :param name: The name for this index, if present.
        :param type: The type for this index which defaults to "search". Alternative values include "vectorSearch".
        :param kwargs: Keyword arguments supplying any additional options.

        .. note:: Search indexes require a MongoDB server version 7.0+ Atlas cluster.
        .. versionadded:: 4.5
        .. versionchanged:: 4.7
           Added the type and kwargs arguments.
        Nr   
definitionrm   )_SearchIndexModel__documentr0   )r^   r   r   rm   r   s        rX   r`   zSearchIndexModel.__init__O  sS    * +-&*DOOF#(2%&*DOOF#v&rW   c                    | j                   S )zThe document for this index.)r   ri   s    rX   r_   zSearchIndexModel.documentl  s     rW   r   )
r   r   r   Optional[str]rm   r   r   r   ru   rv   )ru   r   r   rV   rW   rX   r   r   J  s[    .I
 #"	'%' ' 	'
 ' 
':  rW   r   )1r}   
__future__r   enumtypingr   r   r   r   r   r	   r
   r   bson.raw_bsonr   pymongor   pymongo.collationr   pymongo.commonr   r   pymongo.helpersr   r   r   pymongo.typingsr   r   r   pymongo.write_concernr   pymongo.bulkr   ry   int
_IndexListr   Enumr   rZ   r   r   r   r   r   r   r   r   rV   rW   rX   <module>r      s)   # " 	 	 	 *  8 = I I B B 2" U3c5c7383D)D#EEFFGH'RUWZRZJ[[
 c:o&#tyy >!& !>=! =!@=! =!@V
' V
r;
 ;
|6
	 6
r6
 6
rP Pf% %rW   