U
    g
                     @   sh   d Z ddlmZ ddlmZ ddlmZ ddlmZ ee	Z
ee eedddZeeedd	d
ZdS )aE  This module contains helper functions related to inspecting the program stack.

.. versionadded:: 20.0

Warning:
    Contents of this module are intended to be used internally by the library and *not* by the
    user. Changes to this module are not considered breaking changes and may not be documented in
    the changelog.
    )Path)	FrameType)Optional)
get_logger)framecallerreturnc              
   C   sT   | dkrdS zt | |W S  tk
rN } ztjd|d W Y dS d}~X Y nX dS )a+  Checks if the passed frame was called by the specified file.

    Example:
        .. code:: pycon

            >>> was_called_by(inspect.currentframe(), Path(__file__))
            True

    Arguments:
        frame (:obj:`FrameType`): The frame - usually the return value of
            ``inspect.currentframe()``. If :obj:`None` is passed, the return value will be
            :obj:`False`.
        caller (:obj:`pathlib.Path`): File that should be the caller.

    Returns:
        :obj:`bool`: Whether the frame was called by the specified file.
    NFzJFailed to check if frame was called by `caller`. Assuming that it was not.)exc_info)_was_called_by	Exception_LOGGERdebug)r   r   exc r   =/tmp/pip-unpacked-wheel-swnnwir2/telegram/ext/_utils/stack.pywas_called_by%   s    r   c                 C   sB   t | jj |krdS | jr>| j} t | jj |krdS qdS )NTF)r   f_codeco_filenameresolvef_back)r   r   r   r   r   r
   D   s    r
   N)__doc__pathlibr   typesr   typingr   Ztelegram._utils.loggingr   __name__r   boolr   r
   r   r   r   r   <module>   s   	