o
    j%                     @   sT   d dl Z d dlZd dlZd dlmZ i ZedejZdd Z	dd Z
dd
dZdS )    N)ufuncz[a-z0-9_]+\(.*[,=].*\)c                    sD   dd l }z| }W |S  ty!    fddt D }Y |S w )Nr   c                    s$   g | ]}t  |r|t |fqS  )hasattrgetattr).0xitemr   `/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/skimage/_vendored/numpy_lookfor.py
<listcomp>   s   $ z_getmembers.<locals>.<listcomp>)inspect
getmembers	Exceptiondir)r	   r   membersr   r   r
   _getmembers   s   r   c              
   C   s  ddl }ddlm} | du rd} t| tr-zt|  W n ty&   i  Y S w tj|  } nt| t	s7t| t
rIi }| D ]}|t||| q;|S t| tv rW|sWtt|  S i }|tt| < i }d}| j| fg}	|	r|	d\}
}t||v rzqid|t|< |d7 }d}||rd}z|j}W n ty   d}Y nw |r!t|d	r!|jD ]u}t|D ]m}tj||}tj||d
}tj|r|dr|dd }n
tj|r|}nq|dkrqz)tj}tj}z| t_| t_t|
 d|  W |t_|t_n|t_|t_w W q ty     ty   Y qw qt |D ]j\}}zt!|d|
 d| }t!|dd}W n t"yO   |
 d| }d}Y nw d|vr_|r_| d| }|#|
d spt|t$rnnq%||s|du s||v sq%|	%|
 d| |f q%n'|&|rd}t |D ]\}}|	%|
 d| |f qnt|drd}z|'|}W n t"y   d}Y nw |dur|||f||
< |	sl|S )a  
    Generate docstring cache for given module.

    Parameters
    ----------
    module : str, None, module
        Module for which to generate docstring cache
    import_modules : bool
        Whether to import sub-modules in packages.
    regenerate : bool
        Re-generate the docstring cache

    Returns
    -------
    cache : dict {obj_full_name: (docstring, kind, index), ...}
        Docstring cache for the module, either cached one (regenerate=False)
        or newly generated.

    r   N)StringIOnumpyT   objectmodule__path__z__init__.pyz.py__init__.__name__
__module__class__call__func)(r   ior   
isinstancestr
__import__ImportErrorsysmoduleslisttupleupdate_lookfor_generate_cacheid_lookfor_cachesr   popismodule__all__AttributeErrorr   r   oslistdirpathjoinisfileendswithstdoutstderrKeyboardInterruptBaseExceptionr   r   	NameError
startswithr   appendisclassgetdoc)r   import_modules
regenerater   r   cachemodseenindexstacknamer	   kind_allpthZmod_pathZthis_pyZinit_pyZ	to_importZ
old_stdoutZ
old_stderrnvZ	item_namemod_namedocr   r   r
   r*   "   s   


 
Zr*   TFc              	      s  ddl }t||| g }t|   sdS   D ] \}\}}	}
|	dv r(q| tfddD r<|| qdddddfd	d
 fdd}|j|d dd	 d}|dt
| g}|ddd D ]>} | \}	}dd  dD }z|d  }t|r|d  }W n ty   d}Y nw || d|  qp|s|d |dur|d	| dS t
|dkr| }|d	| dS td	| dS )a  
    Do a keyword search on docstrings.

    A list of objects that matched the search is displayed,
    sorted by relevance. All given keywords need to be found in the
    docstring for it to be returned as a result, but the order does
    not matter.

    Parameters
    ----------
    what : str
        String containing words to look for.
    module : str or list, optional
        Name of module(s) whose docstrings to go through.
    import_modules : bool, optional
        Whether to import sub-modules in packages. Default is True.
    regenerate : bool, optional
        Whether to re-generate the docstring cache. Default is False.
    output : file-like, optional
        File-like object to write the output to. If omitted, use a pager.

    See Also
    --------
    source, info

    Notes
    -----
    Relevance is determined only roughly, by checking if the keywords occur
    in the function name, at the start of a docstring, etc.

    Examples
    --------
    >>> np.lookfor('binary representation') # doctest: +SKIP
    Search results for 'binary representation'
    ------------------------------------------
    numpy.binary_repr
        Return the binary representation of the input number as a string.
    numpy.core.setup_common.long_double_representation
        Given a binary dump as given by GNU od -b, look for long double
    numpy.base_repr
        Return a string representation of a number in the given base system.
    ...

    r   N)r   r   c                 3   s    | ]}| v V  qd S Nr   r   w)rN   r   r
   	<genexpr>   s    zlookfor.<locals>.<genexpr>i  )r   r   r   r   c                    s   d}d |  dd d  |t fddD 7 }|tfddD 7 }|t d 7 }||d7 }|d	 d
 7 }|t| d d7 }|S )Nr   
   c                       g | ]}| v rd qS )   r   rP   )	first_docr   r
   r          z.lookfor.<locals>.relevance.<locals>.<listcomp>c                    rV   )   r   rP   )rG   r   r
   r      rY      rS   r   
   d   i)	r4   lowerstripsplitsumlengetcountmax)rG   ZdocstrrH   rE   r)kind_relevancewhats)rX   rG   r
   	relevance   s    zlookfor.<locals>.relevancec                    s   | g |  R  S rO   r   )a)rB   ri   r   r
   relevance_value  s   z lookfor.<locals>.relevance_value)keyzSearch results for ' '-c                 S   s   g | ]
}|  r|  qS r   )r_   )r   liner   r   r
   r     s    zlookfor.<locals>.<listcomp>rT   r    z
    zNothing found.r\   )pydocr*   r"   r^   r`   itemsallr=   sortr4   rb   r_   _function_signature_research
IndexErrorwriteZgetpagerprint)whatr   r@   rA   outputrs   foundrG   	docstringrH   rE   rk   s	help_textZixZdoclinesrX   pagerr   )rB   rN   rg   ri   rh   r
   lookfor   sN   -


r   )NTFN)r%   r1   rer   r   r,   compileIrw   r   r*   r   r   r   r   r
   <module>   s   
 