a
    \Df                     @  s   d Z ddlmZ ddlZeeZddlmZ ddl	m
Z
 ddlmZ dZdd	d
ddZddddddZdddddZdS )z& Utilities for checking dependencies

    )annotationsN)import_module)
ModuleType)Any)import_optionalimport_requireduses_pandasstrzModuleType | None)mod_namereturnc                 C  sH   z
t | W S  ty   Y n( tyB   d|  d}t| Y n0 dS )a   Attempt to import an optional dependency.

    Silently returns None if the requested module is not available.

    Args:
        mod_name (str) : name of the optional module to try to import

    Returns:
        imported module or None, if import fails

    z"Failed to import optional module ``N)r   ImportError	Exceptionlog	exception)r
   msg r   d/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/bokeh/util/dependencies.pyr   *   s    
r   r   )r
   	error_msgr   c              
   C  s>   z
t | W S  ty8 } zt||W Y d}~n
d}~0 0 dS )aY   Attempt to import a required dependency.

    Raises a RuntimeError if the requested module is not available.

    Args:
        mod_name (str) : name of the required module to try to import
        error_msg (str) : error message to raise when the module is missing

    Returns:
        imported module

    Raises:
        RuntimeError

    N)r   r   RuntimeError)r
   r   er   r   r   r   A   s    
r   r   bool)objr   c                 C  s   t | j}|duo|dS )zo
    Checks if an object is a ``pandas`` object.

    Use this before conditional ``import pandas as pd``.
    Nzpandas.)type
__module__
startswith)r   moduler   r   r   r   V   s    
r   )__doc__
__future__r   logging	getLogger__name__r   	importlibr   typesr   typingr   __all__r   r   r   r   r   r   r   <module>   s   

