
    &gm                    
   S r SSKJr  SSKJrJrJrJrJrJ	r	J
r
  SSKJr  \(       a  SSKJr  SSKJr  \	" S5      r\\\4   r\\   r " S S	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S jrSS jrSS jrg)zFCriteria to select some ServerDescriptions from a TopologyDescription.    )annotations)TYPE_CHECKINGAnyMappingOptionalSequenceTypeVarcast)SERVER_TYPE)ServerDescription)TopologyDescriptionTc                      \ rS rSrSr\SS j5       r        SS jrSS jrSS 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rg)	Selection    z.Input or output of a server selector function.c                    UR                   nS nU H%  nUR                  [        R                  :X  d  M#  Un  O   [	        UUR                   UR
                  U5      $ N)known_serversserver_typer   	RSPrimaryr   common_wire_version)clstopology_descriptionr   primarysds        ]C:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\pymongo/server_selectors.pyfrom_topology_description#Selection.from_topology_description#   s]    ,::B~~!6!66  
   .. 44	
 	
    c                4    Xl         X l        X@l        X0l        g r   )r   server_descriptionsr   r   )selfr   r!   r   r   s        r   __init__Selection.__init__3   s     %9!#6 #6 r   c                X    [        U R                  XR                  U R                  5      $ r   )r   r   r   r   )r"   r!   s     r   with_server_descriptions"Selection.with_server_descriptions?   s*    %%':<T<TVZVbVb
 	
r   c                f    [        U 5      nUR                  (       a  [        UR                  S S9$ g )Nc                6    [        [        U R                  5      $ r   )r
   floatlast_write_date)r   s    r   <lambda>>Selection.secondary_with_max_last_write_date.<locals>.<lambda>H   s    UBL^L^@_r   )key)secondary_server_selectorr!   max)r"   secondariess     r   "secondary_with_max_last_write_date,Selection.secondary_with_max_last_write_dateD   s3    /5**//5_  r   c                d    U R                   (       a  U R                   /O/ nU R                  U5      $ r   )r   r&   )r"   	primariess     r   primary_selectionSelection.primary_selectionL   s&    &*llT\\N	,,Y77r   c                .    U R                   R                  $ r   )r   heartbeat_frequencyr"   s    r   r9   Selection.heartbeat_frequencyQ   s    ((<<<r   c                .    U R                   R                  $ r   )r   topology_typer:   s    r   r=   Selection.topology_typeU   s    ((666r   c                ,    [        U R                  5      $ r   )boolr!   r:   s    r   __bool__Selection.__bool__Y   s    D,,--r   c                     U R                   U   $ r   )r!   )r"   items     r   __getitem__Selection.__getitem__\   s    ''--r   )r   r   r!   r   N)r   r   returnr   )r   r   r!   list[ServerDescription]r   zOptional[int]r   Optional[ServerDescription])r!   rH   rG   r   )rG   rI   )rG   r   )rG   int)rG   r@   )rD   rJ   rG   r   )__name__
__module____qualname____firstlineno____doc__classmethodr   r#   r&   r2   propertyr6   r9   r=   rA   rE   __static_attributes__ r   r   r   r       s    8
 

71
7 5
7 +	
7
 -
7

 8 8 = = 7 7..r   r   c                    U $ r   rS   	selections    r   any_server_selectorrW   `   s    r   c                    U R                  U R                   Vs/ s H  oR                  (       d  M  UPM     sn5      $ s  snf r   )r&   r!   is_readablerV   ss     r   readable_server_selectorr\   d   6    --11C1q]]1C C   ??c                    U R                  U R                   Vs/ s H  oR                  (       d  M  UPM     sn5      $ s  snf r   )r&   r!   is_writablerZ   s     r   writable_server_selectorra   j   r]   r^   c                    U R                  U R                   Vs/ s H$  oR                  [        R                  :X  d  M"  UPM&     sn5      $ s  snf r   )r&   r!   r   r   RSSecondaryrZ   s     r   r/   r/   p   sA    --11^1q]]kF]F]5]1^ ^
   !AAc                    U R                  U R                   Vs/ s H$  oR                  [        R                  :X  d  M"  UPM&     sn5      $ s  snf r   )r&   r!   r   r   	RSArbiterrZ   s     r   arbiter_server_selectorrg   v   sA    --11\1q]]kF[F[5[1\ \rd   c                <    [        U 5      =(       d    [        U 5      $ )z6Like PrimaryPreferred but doesn't use tags or latency.)ra   r/   rU   s    r   "writable_preferred_server_selectorri   |   s    #I.V2KI2VVr   c                   ^  SU 4S jjnUR                  UR                   Vs/ s H  o2" UR                  5      (       d  M  UPM     sn5      $ s  snf )zAll servers matching one tag set.

A tag set is a dict. A server matches if its tags are a superset:
A server tagged {'a': '1', 'b': '2'} matches the tag set {'a': '1'}.

The empty tag set {} matches any server.
c                V   > TR                  5        H  u  pX;  d
  X   U:w  d  M    g   g)NFT)items)server_tagsr.   valuetag_sets      r   
tags_match(apply_single_tag_set.<locals>.tags_match   s-    !--/JC%)9U)B * r   )rm   zMapping[str, Any]rG   r@   )r&   r!   tags)ro   rV   rp   r[   s   `   r   apply_single_tag_setrs      sE     --11H1qZ5G1H Hs   AAc                b    U  H  n[        X!5      nU(       d  M  Us  $    UR                  / 5      $ )a6  All servers match a list of tag sets.

tag_sets is a list of dicts. The empty tag set {} matches any server,
and may be provided at the end of the list as a fallback. So
[{'a': 'value'}, {}] expresses a preference for servers tagged
{'a': 'value'}, but accepts any server if none matches the first
preference.
)rs   r&   )tag_setsrV   ro   with_tag_sets       r   apply_tag_setsrw      s6     +G?< 
 --b11r   c                ,    [        U [        U5      5      $ )z2All near-enough secondaries matching the tag sets.)rw   r/   ru   rV   s     r   #secondary_with_tags_server_selectorrz      s    ($=i$HIIr   c                ,    [        U [        U5      5      $ )z.All near-enough members matching the tag sets.)rw   r\   ry   s     r    member_with_tags_server_selectorr|      s    ($<Y$GHHr   N)rV   r   rG   r   )rV   r   rG   r   )ro   TagSetrV   r   rG   r   )ru   TagSetsrV   r   rG   r   ) rO   
__future__r   typingr   r   r   r   r   r	   r
   pymongo.server_typer   pymongo.server_descriptionr   pymongo.topology_descriptionr   r   strr}   r~   r   rW   r\   ra   r/   rg   ri   rs   rw   rz   r|   rS   r   r   <module>r      s    M " Q Q Q +<@ CL	c	
6
=. =.@W
*2"J
Ir   