o
    „¿Ñg³	  ã                   @  sV   d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 dd	d
„Z
ddd„Zddd„ZdS )z"Determine contexts for coverage.pyé    )Úannotations)Ú	FrameType)ÚcastÚCallableÚOptionalÚSequenceÚcontext_switchersú.Sequence[Callable[[FrameType], Optional[str]]]Úreturnú.Optional[Callable[[FrameType], Optional[str]]]c                   s.   ˆ sdS t ˆ ƒdkrˆ d S d
‡ fdd	„}|S )a  Create a single context switcher from multiple switchers.

    `context_switchers` is a list of functions that take a frame as an
    argument and return a string to use as the new context label.

    Returns a function that composites `context_switchers` functions, or None
    if `context_switchers` is an empty list.

    When invoked, the combined switcher calls `context_switchers` one-by-one
    until a string is returned.  The combined switcher returns None if all
    `context_switchers` return None.
    Né   r   Úframer   r
   úOptional[str]c                   s&   ˆ D ]}|| ƒ}|dur|  S qdS )z,The combiner for multiple context switchers.N© )r   ÚswitcherÚnew_context©r   r   úP/var/www/html/bloggers_ems/venv/lib/python3.10/site-packages/coverage/context.pyÚshould_start_context!   s   ÿz7combine_context_switchers.<locals>.should_start_context©r   r   r
   r   )Úlen)r   r   r   r   r   Úcombine_context_switchers   s   r   r   r   r   c                 C  s&   | j j}| d¡s|dkrt| ƒS dS )z(Is this frame calling a test_* function?ÚtestÚrunTestN)Úf_codeÚco_nameÚ
startswithÚqualname_from_frame)r   r   r   r   r   Ú"should_start_context_test_function,   s   r   c                 C  sÀ   | j }|j}d}|jr|jd dkr| j dd¡}t||dƒ}|du r9| j |¡}|du r/dS tt	|j
d | ƒS t|ddƒ}|du rU|j}tt	|j
d |j d | ƒS tt	|j
d |j ƒS )z5Get a qualified name for the code running in `frame`.Nr   ÚselfÚ.Ú__func__)r   r   Úco_argcountÚco_varnamesÚf_localsÚgetÚgetattrÚ	f_globalsr   ÚstrÚ
__module__Ú	__class__Ú__name__Ú__qualname__)r   ÚcoÚfnameÚmethodr   ÚfuncÚclsr   r   r   r   4   s    r   N)r   r	   r
   r   r   )Ú__doc__Ú
__future__r   Útypesr   Útypingr   r   r   r   r   r   r   r   r   r   r   Ú<module>   s   

 