
    <h$                         S r SSKrSSKJr  SSKrSSKrSSKJr  SSK	J
r
  SSKr\R                  r\S 5       rS rS r0 qS	 rS
 rS rSS jr0 qS r\R.                  r/ \R2                  QSPSPSPSPSPSP74S jrg)a  
Provides a reload() function that acts recursively.

Python's normal :func:`python:reload` function only reloads the module that it's
passed. The :func:`reload` function in this module also reloads everything
imported from that module, which is useful when you're changing files deep
inside a package.

To use this as your default reload function, type this::

    import builtins
    from IPython.lib import deepreload
    builtins.reload = deepreload.reload

A reference to the original :func:`python:reload` is stored in this module as
:data:`original_reload`, so you can restore it later.

This code is almost entirely based on knee.py, which is a Python
re-implementation of hierarchical module import.
    N)contextmanager)
ModuleType)warnc              #      #    [         R                  nU [         l         S v   U[         l        g ! U[         l        f = f7f)N)builtin_mod
__import__)
new_importsaved_imports     iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\IPython/lib/deepreload.pyreplace_import_hookr   (   s0     ))L'K.!-s   ?/ ?<?c                    UnU(       a  [        U [        5      (       d  gU R                  SS5      nUb@  [        US5      (       d  [	        S5      e[        U5      S:X  a  US:  a  [	        S5      egUnO\SU ;  a  gU S   nS	U ;   a  U=U S'   nOBUR                  S
5      nUSs=:  a  U:  a  O  O[	        S5      eUS:  a  SU S'   gUSU =U S'   n[        U5      n[        USS5       H  n UR                  S
SU5      nM     USU n [        R                  U   n
X4$ ! [         a  n	[	        S5      U	eSn	A	ff = f! [         a1  n	US:  a  [        SU-  5        Sn
 Sn	A	X4$ [        SU-  5      U	eSn	A	ff = f)a  
parent, name = get_parent(globals, level)

Return the package that an import is being performed in.  If globals comes
from the module foo.bar.bat (not itself a package), this returns the
sys.modules entry for foo.bar.  If globals is from a package's __init__.py,
the package's entry in sys.modules is returned.

If globals doesn't come from a package or a module in a package, or a
corresponding entry is not found in sys.modules, None is returned.
)N __package__Nrindexz__package__ set to non-stringr   z(Attempted relative import in non-package__name____path__.   z2attempted relative import beyond top-level packagez?Parent module '%.200s' not found while handling absolute importzAParent module '%.200s' not loaded, cannot perform relative import)
isinstancedictgethasattr
ValueErrorlenrfindranger   sysmodulesBaseExceptionr   SystemError)globalslevel
orig_levelpkgnamenamemodnamelastdotdotxeparents              r   
get_parentr-   1   s    J
7D11kk-.Gw))<==w<1qy !KLL W$*% ,33GM"T mmC(G"U" !KLL{)-&,3HW,==GM"T
d)C5!R 	/++c1c*C ! :D	GT" <)  	/ ' (-./	/  G>  ! "F <  8:>? @EFGGs6   -D 
D>  
D;*D66D;>
E9E4%E44E9c                 .   [        U5      S:X  a  U SU4$ UR                  S5      nUS:X  a  [        S5      eUS:  a  UnSnOUSU nX$S-   S nUS:w  a  US-  nX5-  n[        XU5      nUc  X:w  a  [        XU5      nUb  UnUc  [	        SU-  5      eXvU4$ )zZ
mod, name, buf = load_next(mod, altmod, name, buf)

altmod is either None or same as mod
r   Nr   Empty module namer   r   zNo module named %.200s)r   findr   import_submoduleImportError)modaltmodr&   bufr)   subnamenextresults           r   	load_nextr9   z   s     4yA~ D#~
))C.C
ax,--
Qwt*EF|
bys
NCcC0F~#-!&7;C~2T9::    c                    U[         ;   a)  U[        R                  ;   a  [        R                  U   nU$ [        SU5        S[         U'   [        R                  R	                  US5      n Ub  [
        R                  " U5      nO[
        R                  " X5      n [        XX!5        U$ !   U(       a  U[        R                  U'   e = f)z,m = import_submodule(mod, subname, fullname)	Reloadingr   N)		found_nowr   r   printr   	importlibreloadimport_moduleadd_submodule)r3   r6   fullnamemoldms        r   r1   r1      s     9S[[!8KK!& H# 	k8$	({{x.
	$$T*++G9 	ch0H	 (,H%s   *B) B) )Cc                 P    U c  gUc  [         R                  U   n[        XU5        g)zmod.{subname} = submodN)r   r   setattr)r3   submodrC   r6   s       r   rB   rB      s*    
{~X&C&!
r:   c                 D   [        U S5      (       d  gU Hw  n[        US5      (       d  [        S5      eUS:X  a.  U(       a  M.   U R                  n[        XUS5      nU(       d    gMS  [        X5      (       a  Me  [        XUS-   U-   5        My     g! [         a     M  f = f)	z,Handle 'from module import a, b, c' imports.r   Nr   z"Item in ``from list'' not a string*r   r   r   )r   	TypeError__all__ensure_fromlistAttributeErrorr1   )r3   fromlistr5   	recursiveitemallrets          r   rM   rM      s    3
##tX&&@AA3;kk &cQ7 ##Sc	D(89  " s   B
BBc                     [        X5      u  pV[        XTS:  a  SOUX5      u  ppnUnU (       a  [        XX5      u  pnU (       a  M  Uc  [        S5      eU(       d  U$ [        XUS5        U$ )zReplacement for __import__()r   Nr/   )r-   r9   r   rM   )	r&   r"   localsrO   r#   r,   r5   headtails	            r   deep_import_hookrX      sq    W,KF	vtQODD
#D:C $ |,--DC+Kr:   c                    U [         L a  U $ [        U [        5      (       d  [        S5      eU R                  nU[
        R                  ;  a  [        SU-  5      e [        U   $ !   U [        U'    O= f [        R                  " U 5      nO!   U [
        R                  U'   e = f [        R                  5         U$ ! [        R                  5         f = f)zReplacement for reload().z reload() argument must be modulez*reload(): module %.200s not in sys.modules)typesr   r   rK   r   r   r   r2   modules_reloadingr?   r@   clear)rD   r&   newms      r   deep_reload_hookr^      s     	Eza$$:;;::D3;;FMNN$ &&$"#$""D 	
 	!K 	!s*   A$ $A15B B< B""B< <Cr   zos.pathbuiltins__main__numpyznumpy._globalsc                     U H  nS[         U'   M      [        [        5         [        U 5      sSSS5        0 q $ ! , (       d  f       O= f 0 q g! 0 q f = f)a9  Recursively reload all modules used in the given module.  Optionally
takes a list of modules to exclude from reloading.  The default exclude
list contains modules listed in sys.builtin_module_names with additional
sys, os.path, builtins and __main__, to prevent, e.g., resetting
display, exception, and io hooks.
r   N)r=   r   rX   r^   )moduleexcludeis      r   r@   r@     sU    & 	!  !12#F+ 32 	 322 	B	s   A :	A 
AA A)NNNr   )__doc__r_   r   
contextlibr   r?   r   rZ   r   warningsr   r   original_importr   r-   r9   r=   r1   rB   rM   rX   r[   r^   r@   original_reloadbuiltin_module_names r:   r   <module>rm      s   6  %  
   ((. .GR$P 	:
:*,  @ ""
		!	! 	 		
 	 	 	r:   