U
    ð¤ùdY  ã                   @   s  d Z ddlmZmZ ddddddd	d
ddddddddddddddddddgZdZdZdZd Zd!Z	d"Z
dd#lmZ dd$lmZmZ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mZmZmZmZm Z m!Z! dd*l"m#Z# dd+l$m%Z% eZ&e'd,œd-d„Z(ee) ed.œd/d„Z*d0S )1zPython driver for MongoDB.é    )ÚContextManagerÚOptionalÚ	ASCENDINGÚ
DESCENDINGÚGEO2DÚ	GEOSPHEREÚHASHEDÚTEXTÚversion_tupleÚget_version_stringÚ__version__ÚversionÚReturnDocumentÚMAX_SUPPORTED_WIRE_VERSIONÚMIN_SUPPORTED_WIRE_VERSIONÚ
CursorTypeÚMongoClientÚ
DeleteManyÚ	DeleteOneÚ
IndexModelÚ	InsertOneÚ
ReplaceOneÚ
UpdateManyÚ	UpdateOneÚReadPreferenceÚWriteConcernÚhas_cÚtimeouté   éÿÿÿÿZ2dZ2dsphereÚhashedÚtext)Ú_csot)r   r   r
   )r   )r   r   )r   )r   )r   r   r   r   r   r   r   )r   )r   )Úreturnc                  C   s.   zddl m}  W dS  tk
r(   Y dS X dS )zIs the C extension installed?r   ©Ú	_cmessageTFN)Úpymongor%   ÚImportErrorr$   © r(   ú4/tmp/pip-unpacked-wheel-oblwsawz/pymongo/__init__.pyr   m   s
    )Úsecondsr#   c                 C   sJ   t | tttdƒfƒstdƒ‚| r0| dk r0tdƒ‚| dk	r@t| ƒ} t | ¡S )a£  **(Provisional)** Apply the given timeout for a block of operations.

    .. note:: :func:`~pymongo.timeout` is currently provisional. Backwards
       incompatible changes may occur before becoming officially supported.

    Use :func:`~pymongo.timeout` in a with-statement::

      with pymongo.timeout(5):
          client.db.coll.insert_one({})
          client.db.coll2.insert_one({})

    When the with-statement is entered, a deadline is set for the entire
    block. When that deadline is exceeded, any blocking pymongo operation
    will raise a timeout exception. For example::

      try:
          with pymongo.timeout(5):
              client.db.coll.insert_one({})
              time.sleep(5)
              # The deadline has now expired, the next operation will raise
              # a timeout exception.
              client.db.coll2.insert_one({})
      except PyMongoError as exc:
          if exc.timeout:
              print(f"block timed out: {exc!r}")
          else:
              print(f"failed with non-timeout error: {exc!r}")

    When nesting :func:`~pymongo.timeout`, the nested deadline is capped by
    the outer deadline. The deadline can only be shortened, not extended.
    When exiting the block, the previous deadline is restored::

      with pymongo.timeout(5):
          coll.find_one()  # Uses the 5 second deadline.
          with pymongo.timeout(3):
              coll.find_one() # Uses the 3 second deadline.
          coll.find_one()  # Uses the original 5 second deadline.
          with pymongo.timeout(10):
              coll.find_one()  # Still uses the original 5 second deadline.
          coll.find_one()  # Uses the original 5 second deadline.

    :Parameters:
      - `seconds`: A non-negative floating point number expressing seconds, or None.

    :Raises:
      - :py:class:`ValueError`: When `seconds` is negative.

    See :ref:`timeout-example` for more examples.

    .. versionadded:: 4.2
    Nz(timeout must be None, an int, or a floatr   ztimeout cannot be negative)Ú
isinstanceÚintÚfloatÚtypeÚ	TypeErrorÚ
ValueErrorr"   Z_TimeoutContext)r*   r(   r(   r)   r   w   s    4N)+Ú__doc__Útypingr   r   Ú__all__r   r   r   r   r   r	   r&   r"   Zpymongo._versionr   r   r
   Zpymongo.collectionr   Zpymongo.commonr   r   Zpymongo.cursorr   Zpymongo.mongo_clientr   Zpymongo.operationsr   r   r   r   r   r   r   Zpymongo.read_preferencesr   Zpymongo.write_concernr   r   Úboolr   r-   r   r(   r(   r(   r)   Ú<module>   s\   æ$	
