3
]ð]Î|  ã            *   @   s¢  d Z ddlZddlZddlmZ ddlmZmZmZm	Z	 ddl
mZmZ ddlmZmZmZmZ ddlmZ ddlmZ dd	l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$m%Z% ddl&m'Z'm(Z( ddl)m*Z*m+Z+ yddl,m-Z- ee-fZ.W n e/k
�r(   efZ.Y nX d¯Z0de0 Z1dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9dZ:dZ;dZ<dZ=dZ>dZ?dZ@dZAdZBdZCd ZDd!ZEd!ZFd°ZGd±ZHd&ZId'd(„ ZJd)d*„ ZKd+d,„ ZLeeee	d-œZMd.d/„ ZNd0d1„ ZOd2d3„ ZPd4d5„ ZQd6d7„ ZRd8d9„ ZSd:d;„ ZTd<d=„ ZUd>d?„ ZVd@dA„ ZWdBdC„ ZXdDdE„ ZYdFdG„ ZZdHdI„ Z[dJdK„ Z\dLdM„ Z]dNdO„ Z^dPdQ„ Z_dRdS„ Z`dTdU„ ZadVdW„ ZbdXdY„ ZceddZd[d\gƒZed]d^„ Zfd_d`„ Zgdadb„ Zhdcdd„ Zidedf„ Zjdgdh„ Zkdidj„ Zldkdl„ Zmdmdn„ Zndodp„ Zodqdr„ Zpdsdt„ Zqdudv„ ZreddwdxdygƒZsdzd{„ Ztd|d}„ Zud~gdgd€gd�gd‚gdƒgd„gd…gd†gd‡œ	ZveneaefeVee\e\eOe[e\eTe^eWe`eceWeOeOe]e\eSeOe(e'dˆd‰„ eOeSeSeWeOeYeRedŠœ!ZweOeoeOeReOeSeOetebeUe\d‹œZxegehe_e eueWeWepedŒœ	Zyd�dŽd€d�d‚dƒd„d…d†d�œ	Zzd²d³d´dµd¶d·d¸d¹d™œZ{ewj|exƒ x<eevƒD ]0\Z}Z~x$e~D ]Zeewk�rúewe} ewe< �qúW �qìW ewj€ƒ Z�e�j|eyƒ dšd›dœd�dždŸd gZ‚edd¡gƒZƒd¢d£„ Z„d¤d¥„ Z…dºd¦d§„Z†edd¨ddŽd©d~d�gƒZ‡G dªd«„ d«eˆƒZ‰G d¬d­„ d­ejŠƒZ‹dS )»z9Functions and classes common to multiple pymongo modules.é    N)ÚSON)ÚSTANDARDÚPYTHON_LEGACYÚJAVA_LEGACYÚCSHARP_LEGACY)ÚCodecOptionsÚTypeRegistry)ÚabcÚinteger_typesÚ	iteritemsÚstring_type)ÚRawBSONDocument)Ú
MECHANISMS)Úvalidate_compressorsÚvalidate_zlib_compression_level)Ú
DriverInfo)Ú%validate_auto_encryption_opts_or_none)ÚConfigurationError)Ú_validate_event_listeners)ÚReadConcern)Ú_MONGOS_MODESÚ_ServerMode)Úvalidate_cert_reqsÚvalidate_allow_invalid_certs)ÚDEFAULT_WRITE_CONCERNÚWriteConcern)ÚOrderedDicté   i   é   iè  z2.6é   é
   é   é   g      à?é<   g      4@éd   é   Té;   é   é£@  é¤@  i'  c             C   sZ   | }d}| j dƒ}|dkr<| d|… t| |d d… ƒ }}|jdƒrR|dd… }||fS )z5Split a host:port string into (host, int(port)) pair.i‰i  ú:r!   Nú[éÿÿÿÿr,   )ÚrfindÚintÚ
startswith)ÚnodeÚhostÚportÚidx© r4   ú1/tmp/pip-build-20mum3z4/pymongo/pymongo/common.pyÚpartition_nodev   s    
"
r6   c             C   s   t | ƒ\}}|jƒ |fS )z:Split and normalize a node name from an ismaster response.)r6   Úlower)r0   r1   r2   r4   r4   r5   Ú
clean_node‚   s    r8   c             C   s   t d| f ƒ‚dS )z1Raise ConfigurationError with the given key name.zUnknown option %sN)r   )ÚkeyÚdummyr4   r4   r5   Úraise_config_error�   s    r;   )ÚstandardZpythonLegacyZ
javaLegacyZcsharpLegacyc             C   s    t |tƒr|S td| f ƒ‚dS )z(Validates that 'value' is True or False.z%s must be True or FalseN)Ú
isinstanceÚboolÚ	TypeError)ÚoptionÚvaluer4   r4   r5   Úvalidate_boolean›   s    
rB   c             C   s2   t |tƒr(|dkr td| f ƒ‚|dkS t| |ƒS )z8Validates that value is True, False, 'true', or 'false'.ÚtrueÚfalsez)The value of %s must be 'true' or 'false')rC   rD   )r=   r   Ú
ValueErrorrB   )r@   rA   r4   r4   r5   Úvalidate_boolean_or_string¢   s    

rF   c             C   sV   t |tƒr|S t |tƒrDyt|ƒS  tk
rB   td| f ƒ‚Y nX td| f ƒ‚dS )zIValidates that 'value' is an integer (or basestring representation).
    z"The value of %s must be an integerz+Wrong type for %s, value must be an integerN)r=   r
   r   r.   rE   r?   )r@   rA   r4   r4   r5   Úvalidate_integer¬   s    

rG   c             C   s$   t | |ƒ}|dkr td| f ƒ‚|S )zKValidate that 'value' is a positive integer, which does not include 0.
    r   z*The value of %s must be a positive integer)rG   rE   )r@   rA   Úvalr4   r4   r5   Úvalidate_positive_integerº   s
    

rI   c             C   s$   t | |ƒ}|dk r td| f ƒ‚|S )z6Validate that 'value' is a positive integer or 0.
    r   z.The value of %s must be a non negative integer)rG   rE   )r@   rA   rH   r4   r4   r5   Úvalidate_non_negative_integerÄ   s
    

rJ   c             C   s(   |dkr|S t | |ƒ}t|dƒjƒ  |S )z6Validates that 'value' is file-like and readable.
    NÚr)Úvalidate_stringÚopenÚclose)r@   rA   r4   r4   r5   Úvalidate_readableÎ   s
    
rO   c             C   s   |dkr|S t | |ƒS )z9Validate that 'value' is a positive integer or None.
    N)rI   )r@   rA   r4   r4   r5   Ú!validate_positive_integer_or_noneÚ   s    rP   c             C   s   |dkr|S t | |ƒS )z>Validate that 'value' is a positive integer or 0 or None.
    N)rJ   )r@   rA   r4   r4   r5   Ú%validate_non_negative_integer_or_noneâ   s    rQ   c             C   s$   t |tƒr|S td| tjf ƒ‚dS )zbValidates that 'value' is an instance of `basestring` for Python 2
    or `str` for Python 3.
    z2Wrong type for %s, value must be an instance of %sN)r=   r   r?   Ú__name__)r@   rA   r4   r4   r5   rL   ê   s    
rL   c             C   s   |dkr|S t | |ƒS )zEValidates that 'value' is an instance of `basestring` or `None`.
    N)rL   )r@   rA   r4   r4   r5   Úvalidate_string_or_noneô   s    rS   c             C   sH   t |tƒr|S t |tƒr6yt|ƒS  tk
r4   |S X td| f ƒ‚dS )z4Validates that 'value' is an integer or string.
    z7Wrong type for %s, value must be an integer or a stringN)r=   r
   r   r.   rE   r?   )r@   rA   r4   r4   r5   Úvalidate_int_or_basestringü   s    

rT   c             C   sV   t |tƒr|S t |tƒrDyt|ƒ}W n tk
r8   |S X t| |ƒS td| f ƒ‚dS )z4Validates that 'value' is an integer or string.
    zDWrong type for %s, value must be an non negative integer or a stringN)r=   r
   r   r.   rE   rJ   r?   )r@   rA   rH   r4   r4   r5   Ú'validate_non_negative_int_or_basestring
  s    


rU   c             C   sx   d| f }yt |ƒ}W n6 tk
r2   t|ƒ‚Y n tk
rL   t|ƒ‚Y nX d|  k o`dk n  sttd| f ƒ‚|S )z[Validates that 'value' is a float, or can be converted to one, and is
       positive.
    z%s must be an integer or floatr   g    eÍÍAz3%s must be greater than 0 and less than one billion)ÚfloatrE   r?   )r@   rA   Úerrmsgr4   r4   r5   Úvalidate_positive_float  s    

rX   c             C   s   |dks|dkrdS t | |ƒS )zgValidates that 'value' is 0 or a positive float, or can be converted to
    0 or a positive float.
    r   Ú0)rX   )r@   rA   r4   r4   r5   Úvalidate_positive_float_or_zero-  s    rZ   c             C   s   |dkr|S t | |ƒd S )zcValidates a timeout specified in milliseconds returning
    a value in floating point seconds.
    Ng     @�@)rX   )r@   rA   r4   r4   r5   Úvalidate_timeout_or_none6  s    r[   c             C   s8   |dkrt d| f ƒ‚|dks&|dkr*dS t| |ƒd S )zâValidates a timeout specified in milliseconds returning
    a value in floating point seconds for the case where None is an error
    and 0 is valid. Setting the timeout to nothing in the URI string is a
    config error.
    Nz%s cannot be Noner   rY   g     @�@)r   rX   )r@   rA   r4   r4   r5   Úvalidate_timeout_or_zero?  s
    r\   c             C   s   |dks|dkrdS t | |ƒS )zBValidates maxStalenessSeconds according to the Max Staleness Spec.r!   z-1r,   r,   )rI   )r@   rA   r4   r4   r5   Úvalidate_max_stalenessL  s    r]   c             C   s   t |tƒstd|f ƒ‚|S )z Validate a read preference.
    z%r is not a read preference.)r=   r   r?   )r:   rA   r4   r4   r5   Úvalidate_read_preferenceT  s    
r^   c             C   s   |t krtd|f ƒ‚|S )z¸Validate read preference mode for a MongoReplicaSetClient.

    .. versionchanged:: 3.5
       Returns the original ``value`` instead of the validated read preference
       mode.
    z!%s is not a valid read preference)r   rE   )r:   rA   r4   r4   r5   Úvalidate_read_preference_mode\  s    r_   c             C   s(   |t kr$|dkr$td| tt ƒf ƒ‚|S )z+Validate the authMechanism URI option.
    zCRAM-MD5z%s must be in %s)r   rE   Útuple)r@   rA   r4   r4   r5   Úvalidate_auth_mechanismh  s    ra   c             C   s6   yt | S  tk
r0   td|tt ƒf ƒ‚Y nX dS )zAValidate the uuid representation option selected in the URI.
    z7%s is an invalid UUID representation. Must be one of %sN)Ú_UUID_REPRESENTATIONSÚKeyErrorrE   r`   )r:   rA   r4   r4   r5   Úvalidate_uuid_representations  s
    rd   c             C   s‚   t |tƒs|g}g }xh|D ]`}|dkr2|ji ƒ qy"|jtdd„ |jdƒD ƒƒƒ W q tk
rx   td|| f ƒ‚Y qX qW |S )z:Parse readPreferenceTags if passed as a client kwarg.
    Ú c             S   s   g | ]}|j d ƒ‘qS )r*   )Úsplit)Ú.0Útagr4   r4   r5   ú
<listcomp>Š  s   z1validate_read_preference_tags.<locals>.<listcomp>ú,z%r not a valid value for %s)r=   ÚlistÚappendÚdictrf   Ú	ExceptionrE   )ÚnamerA   Ztag_setsZtag_setr4   r4   r5   Úvalidate_read_preference_tags~  s    


rp   ZSERVICE_NAMEÚCANONICALIZE_HOST_NAMEZSERVICE_REALMc             C   s˜   t | |ƒ}i }x„|jdƒD ]v}y|jdƒ\}}W n" tk
rR   td|f ƒ‚Y nX |tkrptd|ttƒf ƒ‚|dkrˆt||ƒ||< q|||< qW |S )z!Validate authMechanismProperties.rj   r*   zTauth mechanism properties must be key:value pairs like SERVICE_NAME:mongodb, not %s.zA%s is not a supported auth mechanism property. Must be one of %s.rq   )rL   rf   rE   Ú_MECHANISM_PROPSr`   rF   )r@   rA   ÚpropsÚoptr9   rH   r4   r4   r5   Ú"validate_auth_mechanism_properties—  s    
ru   c             C   s"   t |tjtfƒstd| f ƒ‚|S )z#Validate the document_class option.zh%s must be dict, bson.son.SON, bson.raw_bson.RawBSONDocument, or a sublass of collections.MutableMapping)Ú
issubclassr	   ÚMutableMappingr   r?   )r@   rA   r4   r4   r5   Úvalidate_document_class®  s    
rx   c             C   s(   |dk	r$t |tƒ r$td| tf ƒ‚|S )z"Validate the type_registry option.Nz%s must be an instance of %s)r=   r   r?   )r@   rA   r4   r4   r5   Úvalidate_type_registry·  s    ry   c             C   s   t |tƒstd| f ƒ‚|S )z!Validates that 'value' is a list.z%s must be a list)r=   rk   r?   )r@   rA   r4   r4   r5   Úvalidate_list¿  s    
rz   c             C   s   |dkr|S t | |ƒS )z)Validates that 'value' is a list or None.N)rz   )r@   rA   r4   r4   r5   Úvalidate_list_or_noneÆ  s    r{   c             C   s"   t |tjtfƒstd| f ƒ‚dS )z/Validates that 'value' is a list or a document.zw%s must either be a list or an instance of dict, bson.son.SON, or any other type that inherits from collections.MappingN)r=   r	   ÚMappingrk   r?   )r@   rA   r4   r4   r5   Úvalidate_list_or_mappingÍ  s    r}   c             C   s   t |tjƒstd| f ƒ‚dS )z=Validate the type of method arguments that expect a document.zf%s must be an instance of dict, bson.son.SON, or any other type that inherits from collections.MappingN)r=   r	   r|   r?   )r@   rA   r4   r4   r5   Úvalidate_is_mappingÕ  s    r~   c             C   s"   t |tjtfƒstd| f ƒ‚dS )zEValidate the type of method arguments that expect a MongoDB document.z„%s must be an instance of dict, bson.son.SON, bson.raw_bson.RawBSONDocument, or a type that inherits from collections.MutableMappingN)r=   r	   rw   r   r?   )r@   rA   r4   r4   r5   Úvalidate_is_document_typeÝ  s    r   c             C   s:   |dkr|S t | |ƒ t|jdƒƒdkr6td| f ƒ‚|S )zValidate the appname option.Nzutf-8é€   z%s must be <= 128 bytes)rL   ÚlenÚencoderE   )r@   rA   r4   r4   r5   Úvalidate_appname_or_noneæ  s    
rƒ   c             C   s(   |dkr|S t |tƒs$td| f ƒ‚|S )z Validate the driver keyword arg.Nz$%s must be an instance of DriverInfo)r=   r   r?   )r@   rA   r4   r4   r5   Úvalidate_driver_or_noneñ  s
    
r„   c             C   s&   |dkr|S t |ƒs"td| f ƒ‚|S )z%Validates that 'value' is a callable.Nz%s must be a callable)ÚcallablerE   )r@   rA   r4   r4   r5   Úvalidate_is_callable_or_noneú  s
    r†   c             C   s<   t d| ƒ | r8t| tƒ r8tt| ƒƒ}|jdƒr8tdƒ‚dS )z Validate a replacement document.Úreplacementú$z'replacement can not include $ operatorsN)r~   r=   r   ÚnextÚiterr/   rE   )r‡   Úfirstr4   r4   r5   Úvalidate_ok_for_replace  s
    

rŒ   c             C   sJ   t d| ƒ | stdƒ‚t| tƒ }tt| ƒƒ}|rF|jdƒ rFtdƒ‚dS )zValidate an update document.Úupdatezupdate cannot be emptyrˆ   z"update only works with $ operatorsN)r}   rE   r=   rk   r‰   rŠ   r/   )r�   Zis_documentr‹   r4   r4   r5   Úvalidate_ok_for_update  s    
rŽ   ÚstrictÚreplaceÚignorec             C   s    |t krtd|tt ƒf ƒ‚|S )zFValidate the Unicode decode error handler option of CodecOptions.
    z@%s is an invalid Unicode decode error handler. Must be one of %s)Ú_UNICODE_DECODE_ERROR_HANDLERSrE   r`   )r:   rA   r4   r4   r5   Ú%validate_unicode_decode_error_handler  s    r“   c             C   s&   |dk	r"t |tjƒ r"td| ƒ‚|S )zValidate the tzinfo option
    Nz)%s must be an instance of datetime.tzinfo)r=   ÚdatetimeÚtzinfor?   )r:   rA   r4   r4   r5   Úvalidate_tzinfo'  s    r–   ÚjÚwtimeoutÚsslÚssl_cert_reqsÚssl_match_hostnameÚssl_crlfileÚssl_ca_certsZssl_certfileÚssl_pem_passphrase)	ÚjournalÚ
wtimeoutmsÚtlsÚtlsallowinvalidcertificatesÚtlsallowinvalidhostnamesÚ
tlscrlfileÚ	tlscafileÚtlscertificatekeyfileÚtlscertificatekeyfilepasswordc              G   s
   t | Ž  S )N)rF   )Úxr4   r4   r5   Ú<lambda>[  s    r©   )!ÚappnameZauthmechanismÚauthmechanismpropertiesZ
authsourceZcompressorsÚconnecttimeoutmsÚheartbeatfrequencymsrŸ   ZlocalthresholdmsÚmaxidletimemsZmaxpoolsizeÚmaxstalenesssecondsZreadconcernlevelZreadpreferenceZreadpreferencetagsZ
replicasetZ
retryreadsZretrywritesÚserverselectiontimeoutmsÚsockettimeoutmsZssl_keyfiler¡   r¢   rš   r£   r›   r¥   r¦   r§   ZtlsinsecureÚwr    Zzlibcompressionlevel)ÚconnectZdriverÚfsyncZminpoolsizeZsocketkeepaliver¤   Ztz_awareZunicode_decode_error_handlerZuuidrepresentationÚwaitqueuemultipleÚwaitqueuetimeoutms)	Zdocument_classZtype_registryÚread_preferenceZevent_listenersr•   ÚusernameÚpasswordZserver_selectorZauto_encryption_optsrŸ   r    )	r—   r˜   r¡   r¢   r£   r¤   r¥   r¦   r§   ÚrenamedÚ
wTimeoutMSÚtlsAllowInvalidCertificatesÚtlsAllowInvalidHostnamesÚ
tlsCRLFileÚ	tlsCAFileÚtlsCertificateKeyFilePasswordÚremovedúqInstead of using waitQueueMultiple to bound queuing, limit the size of the thread pool in your application server)r—   r˜   rš   r›   rœ   r�   rž   rµ   r¬   r­   r®   r¯   r°   r±   r¶   r«   c             C   s,   t | |ƒ\}}|tkr$td| f ƒ‚||fS )z1Validate optional authentication parameters.
    z!Unknown authentication option: %s)ÚvalidateÚ_AUTH_OPTIONSr   )r@   rA   r7   r4   r4   r5   Úvalidate_auth_optionÆ  s
    
rÅ   c             C   s&   | j ƒ }tj|tƒ}|| |ƒ}||fS )z!Generic validation function.
    )r7   Ú
VALIDATORSÚgetr;   )r@   rA   r7   Ú	validatorr4   r4   r5   rÃ   Ð  s    
rÃ   c       
         sÂ   t ˆ tƒr&tƒ }dd„ }‡ fdd„}ni }dd„ }dd„ }x‚tˆ ƒD ]v\}}||ƒ}ytj|tƒ}|||ƒ}W n> tttfk
r¬ }	 z|ršt	j
t|	ƒƒ n‚ W Y dd}	~	X qDX ||||ƒ< qDW |S )a  Validate each entry in options and raise a warning if it is not valid.
    Returns a copy of options with invalid entries removed.

    :Parameters:
        - `opts`: A dict containing MongoDB URI options.
        - `warn` (optional): If ``True`` then warnings will be logged and
          invalid options will be ignored. Otherwise, invalid options will
          cause errors.
    c             S   s   | S )Nr4   )r¨   r4   r4   r5   r©   å  s    z'get_validated_options.<locals>.<lambda>c                s
   ˆ j | ƒS )N)Ú	cased_key)r¨   )Úoptionsr4   r5   r©   æ  s    c             S   s   | j ƒ S )N)r7   )r¨   r4   r4   r5   r©   é  s    c             S   s   | S )Nr4   )r¨   r4   r4   r5   r©   ê  s    N)r=   Ú_CaseInsensitiveDictionaryr   ÚURI_OPTIONS_VALIDATOR_MAPrÇ   r;   rE   r?   r   ÚwarningsÚwarnÚstr)
rÊ   rÎ   Zvalidated_optionsZget_normed_keyZget_setter_keyrt   rA   Z
normed_keyrÈ   Úexcr4   )rÊ   r5   Úget_validated_optionsÙ  s&    

rÑ   r²   r´   c               @   sX   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZdd	„ Zed
d„ ƒZ	dd„ Z
edd„ ƒZdS )Ú
BaseObjectz™A base class that provides attributes and methods common
    to multiple pymongo classes.

    SHOULD NOT BE USED BY DEVELOPERS EXTERNAL TO MONGODB.
    c             C   sj   t |tƒstdƒ‚|| _t |tƒs0td|f ƒ‚|| _t |tƒsHtdƒ‚|| _t |tƒs`tdƒ‚|| _	d S )NzDcodec_options must be an instance of bson.codec_options.CodecOptionszT%r is not valid for read_preference. See pymongo.read_preferences for valid options.zGwrite_concern must be an instance of pymongo.write_concern.WriteConcernzDread_concern must be an instance of pymongo.read_concern.ReadConcern)
r=   r   r?   Ú_BaseObject__codec_optionsr   Ú_BaseObject__read_preferencer   Ú_BaseObject__write_concernr   Ú_BaseObject__read_concern)ÚselfÚcodec_optionsr·   Úwrite_concernÚread_concernr4   r4   r5   Ú__init__  s    




zBaseObject.__init__c             C   s   | j S )zdRead only access to the :class:`~bson.codec_options.CodecOptions`
        of this instance.
        )rÓ   )r×   r4   r4   r5   rØ   &  s    zBaseObject.codec_optionsc             C   s   | j S )zÈRead only access to the :class:`~pymongo.write_concern.WriteConcern`
        of this instance.

        .. versionchanged:: 3.0
          The :attr:`write_concern` attribute is now read only.
        )rÕ   )r×   r4   r4   r5   rÙ   -  s    zBaseObject.write_concernc             C   s   |r|j rtS | jS )zKRead only access to the write concern of this instance or session.
        )Zin_transactionr   rÙ   )r×   Úsessionr4   r4   r5   Ú_write_concern_for7  s    
zBaseObject._write_concern_forc             C   s   | j S )z¥Read only access to the read preference of this instance.

        .. versionchanged:: 3.0
          The :attr:`read_preference` attribute is now read only.
        )rÔ   )r×   r4   r4   r5   r·   ?  s    zBaseObject.read_preferencec             C   s   |r|j ƒ p| jS | jS )zMRead only access to the read preference of this instance or session.
        )Z_txn_read_preferencerÔ   )r×   rÜ   r4   r4   r5   Ú_read_preference_forH  s    zBaseObject._read_preference_forc             C   s   | j S )z„Read only access to the :class:`~pymongo.read_concern.ReadConcern`
        of this instance.

        .. versionadded:: 3.2
        )rÖ   )r×   r4   r4   r5   rÚ   P  s    zBaseObject.read_concernN)rR   Ú
__module__Ú__qualname__Ú__doc__rÛ   ÚpropertyrØ   rÙ   rÝ   r·   rÞ   rÚ   r4   r4   r4   r5   rÒ     s   
	rÒ   c               @   s�   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zd"dd„Zdd„ Zdd„ Zdd„ Zd#dd„Zdd„ Zd d!„ ZdS )$rË   c             O   s    i | _ i | _| jt||Žƒ d S )N)Ú%_CaseInsensitiveDictionary__casedkeysÚ _CaseInsensitiveDictionary__datar�   rm   )r×   ÚargsÚkwargsr4   r4   r5   rÛ   [  s    z#_CaseInsensitiveDictionary.__init__c             C   s   |j ƒ | jkS )N)r7   rä   )r×   r9   r4   r4   r5   Ú__contains__`  s    z'_CaseInsensitiveDictionary.__contains__c             C   s
   t | jƒS )N)r�   rä   )r×   r4   r4   r5   Ú__len__c  s    z"_CaseInsensitiveDictionary.__len__c             C   s   dd„ | j D ƒS )Nc             s   s   | ]
}|V  qd S )Nr4   )rg   r9   r4   r4   r5   ú	<genexpr>g  s    z6_CaseInsensitiveDictionary.__iter__.<locals>.<genexpr>)rã   )r×   r4   r4   r5   Ú__iter__f  s    z#_CaseInsensitiveDictionary.__iter__c                s   t ‡ fdd„ˆ D ƒƒS )Nc                s   i | ]}ˆ j | ˆ j| “qS r4   )rä   rã   )rg   Úk)r×   r4   r5   ú
<dictcomp>j  s    z7_CaseInsensitiveDictionary.__repr__.<locals>.<dictcomp>)rÏ   )r×   r4   )r×   r5   Ú__repr__i  s    z#_CaseInsensitiveDictionary.__repr__c             C   s    |j ƒ }|| j|< || j|< d S )N)r7   rã   rä   )r×   r9   rA   Úlc_keyr4   r4   r5   Ú__setitem__l  s    
z&_CaseInsensitiveDictionary.__setitem__c             C   s   | j |jƒ  S )N)rä   r7   )r×   r9   r4   r4   r5   Ú__getitem__q  s    z&_CaseInsensitiveDictionary.__getitem__c             C   s   |j ƒ }| j|= | j|= d S )N)r7   rã   rä   )r×   r9   rî   r4   r4   r5   Ú__delitem__t  s    z&_CaseInsensitiveDictionary.__delitem__c             C   sJ   t |tjƒstS t| ƒt|ƒkr$dS x |D ]}| | || kr*dS q*W dS )NFT)r=   r	   r|   ÚNotImplementedr�   )r×   Úotherr9   r4   r4   r5   Ú__eq__y  s    
z!_CaseInsensitiveDictionary.__eq__Nc             C   s   | j j|jƒ |ƒS )N)rä   rÇ   r7   )r×   r9   Údefaultr4   r4   r5   rÇ   „  s    z_CaseInsensitiveDictionary.getc             O   s*   |j ƒ }| jj|d ƒ | jj|f|ž|ŽS )N)r7   rã   Úpoprä   )r×   r9   rå   ræ   rî   r4   r4   r5   rö   ‡  s    z_CaseInsensitiveDictionary.popc             C   s"   | j jƒ \}}| jj|ƒ}||fS )N)rã   Úpopitemrä   rö   )r×   rî   rÉ   rA   r4   r4   r5   r÷   Œ  s    z"_CaseInsensitiveDictionary.popitemc             C   s   | j jƒ  | jjƒ  d S )N)rã   Úclearrä   )r×   r4   r4   r5   rø   ‘  s    
z _CaseInsensitiveDictionary.clearc             C   s6   |j ƒ }|| kr| j| S || j|< || j|< |S d S )N)r7   rä   rã   )r×   r9   rõ   rî   r4   r4   r5   Ú
setdefault•  s    


z%_CaseInsensitiveDictionary.setdefaultc             C   sJ   t |tƒr,x:|D ]}|| | |j|ƒ< qW nx|D ]}|| | |< q2W d S )N)r=   rË   rÉ   )r×   ró   r9   r4   r4   r5   r�   ž  s
    


z!_CaseInsensitiveDictionary.updatec             C   s   | j |jƒ  S )N)rã   r7   )r×   r9   r4   r4   r5   rÉ   ¦  s    z$_CaseInsensitiveDictionary.cased_key)N)N)rR   rß   rà   rÛ   rç   rè   rê   rí   rï   rð   rñ   rô   rÇ   rö   r÷   rø   rù   r�   rÉ   r4   r4   r4   r5   rË   Z  s    

	rË   i   i   )r&   )r'   r(   r)   )rº   rŸ   )rº   r»   )rº   r¼   )rº   r½   )rº   r¾   )rº   r¿   )rº   rÀ   )rÁ   rÂ   )T)Œrá   r”   rÍ   Zbsonr   Zbson.binaryr   r   r   r   Zbson.codec_optionsr   r   Zbson.py3compatr	   r
   r   r   Zbson.raw_bsonr   Zpymongo.authr   Zpymongo.compression_supportr   r   Zpymongo.driver_infor   Zpymongo.encryption_optionsr   Zpymongo.errorsr   Zpymongo.monitoringr   Zpymongo.read_concernr   Zpymongo.read_preferencesr   r   Zpymongo.ssl_supportr   r   Zpymongo.write_concernr   r   Úcollectionsr   ZORDERED_TYPESÚImportErrorZMAX_BSON_SIZEZMAX_MESSAGE_SIZEZMIN_WIRE_VERSIONZMAX_WIRE_VERSIONZMAX_WRITE_BATCH_SIZEZMIN_SUPPORTED_SERVER_VERSIONZMIN_SUPPORTED_WIRE_VERSIONZMAX_SUPPORTED_WIRE_VERSIONZHEARTBEAT_FREQUENCYZKILL_CURSOR_FREQUENCYZEVENTS_QUEUE_FREQUENCYZSERVER_SELECTION_TIMEOUTZMIN_HEARTBEAT_INTERVALZMIN_SRV_RESCAN_INTERVALZCONNECT_TIMEOUTZMAX_POOL_SIZEZMIN_POOL_SIZEZMAX_IDLE_TIME_MSZMAX_IDLE_TIME_SECZWAIT_QUEUE_TIMEOUTZLOCAL_THRESHOLD_MSZRETRY_WRITESZRETRY_READSZCOMMAND_NOT_FOUND_CODESZUNAUTHORIZED_CODESZ_MAX_END_SESSIONSr6   r8   r;   rb   rB   rF   rG   rI   rJ   rO   rP   rQ   rL   rS   rT   rU   rX   rZ   r[   r\   r]   r^   r_   ra   rd   rp   Ú	frozensetrr   ru   rx   ry   rz   r{   r}   r~   r   rƒ   r„   r†   rŒ   rŽ   r’   r“   r–   ZURI_OPTIONS_ALIAS_MAPrÌ   ZNONSPEC_OPTIONS_VALIDATOR_MAPZKW_VALIDATORSZINTERNAL_URI_OPTION_NAME_MAPZURI_OPTIONS_DEPRECATION_MAPr�   ÚoptnameÚaliasesÚaliasÚcopyrÆ   ZTIMEOUT_OPTIONSrÄ   rÅ   rÃ   rÑ   ZWRITE_CONCERN_OPTIONSÚobjectrÒ   rw   rË   r4   r4   r4   r5   Ú<module>   s–  



						


 





	
$S