o
    éT•jd	  ã                   @   sd   d dl Z d dlZd dlZd dlZd dlZddlmZ dd„ Zdd„ Zdd	„ Z	ddd„Z
ddd„ZdS )é    Né   )Ú	constantsc                 C   sV   t  | ¡} t  | ¡r| j}|j|jfS t| tjƒrt	| j
ƒS t| tjƒr)t	| j
ƒS d S ©N)ÚinspectÚunwrapÚ
isfunctionÚ__code__Úco_filenameÚco_firstlinenoÚ
isinstanceÚ	functoolsÚpartialÚ_get_function_sourceÚfuncÚpartialmethod)r   Úcode© r   ú-/usr/lib/python3.10/asyncio/format_helpers.pyr   
   s   



r   c                 C   s8   t | |d ƒ}t| ƒ}|r|d|d › d|d › �7 }|S )Nz at r   ú:r   )Ú_format_callbackr   )r   ÚargsÚ	func_reprÚsourcer   r   r   Ú_format_callback_source   s
   r   c                 C   sH   g }| r|  dd„ | D ƒ¡ |r|  dd„ | ¡ D ƒ¡ d d |¡¡S )z…Format function arguments and keyword arguments.

    Special case for a single parameter: ('hello',) is formatted as ('hello').
    c                 s   s   � | ]}t  |¡V  qd S r   ©ÚreprlibÚrepr)Ú.0Úargr   r   r   Ú	<genexpr>&   s   € z*_format_args_and_kwargs.<locals>.<genexpr>c                 s   s(   � | ]\}}|› d t  |¡› �V  qdS )ú=Nr   )r   ÚkÚvr   r   r   r   (   s   €& z({})z, )ÚextendÚitemsÚformatÚjoin)r   Úkwargsr$   r   r   r   Ú_format_args_and_kwargs   s   r(   Ú c                 C   s„   t | tjƒrt||ƒ| }t| j| j| j|ƒS t| dƒr#| j	r#| j	}nt| dƒr/| j
r/| j
}nt| ƒ}|t||ƒ7 }|r@||7 }|S )NÚ__qualname__Ú__name__)r   r   r   r(   r   r   r   ÚkeywordsÚhasattrr*   r+   r   )r   r   r'   Úsuffixr   r   r   r   r   ,   s   r   c                 C   sD   | du r	t  ¡ j} |du rtj}tjjt | ¡|dd�}| 	¡  |S )zlReplacement for traceback.extract_stack() that only does the
    necessary work for asyncio debug mode.
    NF)ÚlimitÚlookup_lines)
ÚsysÚ	_getframeÚf_backr   ÚDEBUG_STACK_DEPTHÚ	tracebackÚStackSummaryÚextractÚ
walk_stackÚreverse)Úfr/   Ústackr   r   r   Úextract_stack>   s   
þr<   )r)   )NN)r   r   r   r1   r5   r)   r   r   r   r(   r   r<   r   r   r   r   Ú<module>   s    
