
    @h-                    d    S r SSKJr  SSKJr  SSKJrJrJr  SSK	J
r
Jr  SSKJr   " S S5      rg	)
z@Tools for manipulating DBRefs (references to MongoDB documents).    )annotations)deepcopy)AnyMappingOptional)_getstate_slots_setstate_slots)SONc                      \ rS rSrSrSr\r\r	Sr
  S           SS jjr\SS j5       r\SS j5       r\SS	 j5       rSS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)DBRef   z,A reference to a document stored in MongoDB.)__collection__id
__database__kwargsd   Nc                   [        U[        5      (       d  [        S[        U5       35      eUb,  [        U[        5      (       d  [        S[        U5       35      eXl        X l        X0l        UR                  U=(       d    0 5        XPl        g)a  Initialize a new :class:`DBRef`.

Raises :class:`TypeError` if `collection` or `database` is not
an instance of :class:`str`. `database` is optional and allows
references to documents to work across databases. Any additional
keyword arguments will create additional fields in the resultant
embedded document.

:param collection: name of the collection the document is stored in
:param id: the value of the document's ``"_id"`` field
:param database: name of the database to reference
:param kwargs: additional keyword arguments will
    create additional, custom fields

.. seealso:: The MongoDB documentation on `dbrefs <https://dochub.mongodb.org/core/dbrefs>`_.
z+collection must be an instance of str, not Nz)database must be an instance of str, not )	
isinstancestr	TypeErrortype_DBRef__collection
_DBRef__id_DBRef__databaseupdate_DBRef__kwargs)self
collectioniddatabase_extrakwargss         OC:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\bson/dbref.py__init__DBRef.__init__"   sy    0 *c**I$zJZI[\]]
8S(A(AGXGWXYY&	"fl#    c                    U R                   $ )z(Get the name of this DBRef's collection.)r   r   s    r#   r   DBRef.collectionE   s        r&   c                    U R                   $ )zGet this DBRef's _id.)r   r(   s    r#   r   DBRef.idJ   s     yyr&   c                    U R                   $ )z_Get the name of this DBRef's database.

Returns None if this DBRef doesn't specify a database.
)r   r(   s    r#   r    DBRef.databaseO   s     r&   c                V     U R                   U   $ ! [         a    [        U5      S ef = fN)r   KeyErrorAttributeError)r   keys     r#   __getattr__DBRef.__getattr__W   s2    	0==%% 	0 %4/	0s    (c                    [        SU R                  4SU R                  4/5      nU R                  b  U R                  US'   UR	                  U R
                  5        U$ )zcGet the SON document representation of this DBRef.

Generally not needed by application developers
z$refz$idz$db)r
   r   r   r    r   r   )r   docs     r#   as_docDBRef.as_doc]   sQ    
 FDOO,udgg.>?@==$CJ

4==!
r&   c           
     R   SR                  U R                  R                  5        VVs/ s H  u  pSU SU< 3PM     snn5      nU R                  c!  SU R                  < SU R
                  < U S3$ SU R                  < SU R
                  < SU R                  < U S3$ s  snnf )N z, =zDBRef())joinr   itemsr    r   r   )r   kvextras       r#   __repr__DBRef.__repr__h   s    DMM4G4G4IJ4IDA2aS!4IJK== DOO.bE7!DD*"TWWKr$--9J5'QRSS Ks   B#
c                    [        U[        5      (       a`  U R                  U R                  U R                  U R
                  4nUR                  UR                  UR                  UR
                  4nX#:H  $ [        $ r/   )r   r   r   r   r   r   NotImplemented)r   otherusthems       r#   __eq__DBRef.__eq__n   s_    eU##//4#4#4diiOB$$e&8&8%**ennUD:r&   c                    X:X  + $ r/    )r   rF   s     r#   __ne__DBRef.__ne__u   s      r&   c                    [        U R                  U R                  U R                  [	        [        U R                  R                  5       5      5      45      $ )z)Get a hash value for this :class:`DBRef`.)hashr   r   r   tuplesortedr   r>   r(   s    r#   __hash__DBRef.__hash__x   s@    		4??E&I\I\I^B_<`a
 	
r&   c           	         [        [        U R                  U5      [        U R                  U5      [        U R                  U5      [        U R
                  U5      5      $ )z'Support function for `copy.deepcopy()`.)r   r   r   r   r   r   )r   memos     r#   __deepcopy__DBRef.__deepcopy__~   sI    T&&-TYY%T__d+T]]D)	
 	
r&   )r   r   r   r   )NN)r   r   r   r   r    Optional[str]r!   zOptional[Mapping[str, Any]]r"   r   returnNone)rZ   r   )rZ   r   )rZ   rY   )r2   r   rZ   r   )rZ   zSON[str, Any])rF   r   rZ   bool)rZ   int)rV   r   rZ   r   )__name__
__module____qualname____firstlineno____doc__	__slots__r   __getstate__r	   __setstate___type_markerr$   propertyr   r   r    r3   r7   rB   rI   rM   rS   rW   __static_attributes__rL   r&   r#   r   r      s    6@I"L"LL #'.2!! !  	!
 ,! ! 
!F ! !    0	T!

r&   r   N)rb   
__future__r   copyr   typingr   r   r   bson._helpersr   r	   bson.sonr
   r   rL   r&   r#   <module>rn      s)    G "  ) ) : l
 l
r&   