a
    �˜ëjÃ  ã                   @   s„   d Z ddlmZmZ eƒ Zdd„ Zdd„ Zdd„ Ze	eeeƒZ
d	d
„ Ze	eƒZG dd„ deƒZG dd„ deƒZddddœdd„ZdS )aq  The `with_doc` decorator: override the docstring that introspection tools
see for a wrapped callable without mutating the wrapped function itself.
Accepts the docstring directly, or a factory that derives it from the
wrapped function at decoration time.

This is the companion of `with_signature`, which overrides the signature in
the same way. Assigning to `__doc__` on an ordinary wrapt wrapper writes
through to the wrapped function, because `__doc__` on every proxy delegates
to the wrapped object, so a wrapper carrying its own docstring is the only
way to change what is reported without touching the wrapped function.
é   )ÚBoundFunctionWrapperÚFunctionWrapperc                 C   s   | j }|tu r| jjS |S ©N©Ú	_self_docÚ_NO_DOC_OVERRIDEÚ__wrapped__Ú__doc__©ÚselfÚdoc© r   úH/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/wrapt/doc.pyÚ_get_doc*   s    r   c                 C   s   | j tu r|| j_n|| _ d S r   r   )r   Úvaluer   r   r   Ú_set_doc1   s    

r   c                 C   s   | j tu r| j`nt| _ d S r   r   )r   r   r   r   Ú_del_doc8   s    
r   c                 C   s   | j j}|tu r| jjS |S r   )Z_self_parentr   r   r   r	   r
   r   r   r   Ú_get_bound_docF   s    r   c                   @   s   e Zd ZeZdS )Ú_BoundDocFunctionWrapperN)Ú__name__Ú
__module__Ú__qualname__Ú_BOUND_DOC_PROPERTYr	   r   r   r   r   r   P   s   r   c                       s$   e Zd ZeZeZ‡ fdd„Z‡  ZS )Ú_DocFunctionWrapperc                    s   t ƒ  ||¡ || _d S r   )ÚsuperÚ__init__r   )r   ÚwrappedÚwrapperr   ©Ú	__class__r   r   r   Y   s    z_DocFunctionWrapper.__init__)	r   r   r   Ú_DOC_PROPERTYr	   r   Z__bound_function_wrapper__r   Ú__classcell__r   r   r   r   r   T   s   r   N©r   Úfactoryc                  sR   ˆ du rˆdu rt dƒ‚ˆ dur0ˆdur0t dƒ‚‡ ‡fdd„}| du rJ|S || ƒS )aD  Override the docstring of a wrapped callable.

    Exactly one of `doc` or `factory` must be supplied:

    - `doc`: the docstring to report.
    - `factory`: a callable `factory(wrapped)` invoked at decoration time
      that returns the docstring to report.

    The resulting wrapper reports the override as its `__doc__`, and so it
    is what `help()` and `pydoc` display. The wrapped function is not
    mutated, and assigning to `__doc__` on the wrapper replaces the override
    rather than writing through to the wrapped function. Calling behaviour
    is unchanged.
    Nz)with_doc requires one of doc= or factory=z-with_doc accepts only one of doc= or factory=c                    s*   dd„ }ˆd urˆ| ƒ}nˆ }t | ||ƒS )Nc                 S   s   | |i |¤ŽS r   r   )r   ÚinstanceÚargsÚkwargsr   r   r   Ú_wrappert   s    z.with_doc.<locals>._decorator.<locals>._wrapper)r   )r   r'   Zresolvedr"   r   r   Ú
_decorators   s
    
zwith_doc.<locals>._decorator)Ú	TypeError)r   r   r#   r(   r   r"   r   Úwith_doc^   s    r*   )N)r	   Z	__wrapt__r   r   Úobjectr   r   r   r   Úpropertyr    r   r   r   r   r*   r   r   r   r   Ú<module>   s   
