
    GhB                        S r SSKrSSKrSSKrSSKJr  SSKrSSKrSSK	r	SSK
r
SSKJr   SSKJrJr  SSKJrJr  SSKJr  SSKJrJrJr  SSKJr  SS	KJr  SS
KJr   SSK J!r!  SSK#J$r$  \%" 5       r&\RN                  " \RP                  " \)5      5      r*       SS jr+      SS jr, SS jr- SS jr.S r/SS jr0SS jr1SS jr2S r3g! \ a    SSKJrJr   Nf = f! \ a	    SSK"J!r!   Nf = f)z?Utilities for installing Javascript extensions for the notebook    N)Path)PackageNotFoundErrorversion)basenamenormpath)join)ENV_JUPYTER_PATHSYSTEM_JUPYTER_PATHjupyter_data_dir)ensure_dir_exists)ArgumentConflict)get_federated_extensions)load   )_test_overlapc                    Sn[        X7US9n	[        U	5        [        U [        [        45      (       a  Sn
[        U
5      eU(       d  [        [        U 5      5      n[        [        X5      5      nU(       a  [        R                  R                  U5      (       a  U(       a  UR                  SU 35        [        R                  R                  U5      (       a;  [        R                  R                  U5      (       d  [        R                   " U5        O[        R"                  " U5        [        R$                  " [        R                  R'                  U5      SS9  U(       a  [        R                  R)                  U 5      n [        R                  R+                  U5      (       d7  U(       a  UR                  SU SU  35         [        R,                  " X5        U$ [        R                  R                  U5      (       d  U S3n
[5        U
5      e U$ [        R                  R                  U 5      (       a  [        [        R                  R)                  U 5      S5      n [        R6                  " U 5       H  u  pn[        X[9        U 5      S 5      n[        R                  R+                  U5      (       d1  U(       a  UR                  SU 35        [        R$                  " U5        U H&  n[        UU5      n[        UU5      n[;        UUUS9  M(     M     U$ U n[;        UXS9  U$ ! [.         a=  n[0        R0                  " 5       R3                  S	5      (       a  S
n
[/        U
5      Uee SnAff = f)a  Install a prebuilt extension for JupyterLab

Stages files and/or directories into the labextensions directory.
By default, this compares modification time, and only stages files that need updating.
If `overwrite` is specified, matching files are purged before proceeding.

Parameters
----------

path : path to file, directory, zip or tarball archive, or URL to install
    By default, the file will be installed with its base name, so '/path/to/foo'
    will install to 'labextensions/foo'. See the destination argument below to change this.
    Archives (zip or tarballs) will be extracted into the labextensions directory.
user : bool [default: False]
    Whether to install to the user's labextensions directory.
    Otherwise do a system-wide install (e.g. /usr/local/share/jupyter/labextensions).
overwrite : bool [default: False]
    If True, always install the files, regardless of what may already be installed.
symlink : bool [default: True]
    If True, create a symlink in labextensions, rather than copying files.
    Windows support for symlinks requires a permission bit which only admin users
    have by default, so don't rely on it.
labextensions_dir : str [optional]
    Specify absolute path of labextensions directory explicitly.
destination : str [optional]
    name the labextension is installed to.  For example, if destination is 'foo', then
    the source file will be installed to 'labextensions/foo', regardless of the source name.
logger : Jupyter logger [optional]
    Logger instance to use
N)user
sys_prefixlabextensions_dirzpath must be a string pointing to a single extension to install; call this function multiple times to install multiple extensionsz
Removing: T)exist_okzSymlinking:  -> WindowszSymlinks can be activated on Windows 10 for Python version 3.8 or higher by activating the 'Developer Mode'. That may not be allowed by your administrators.
See https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-developmentz exists and is not a symlink zMaking directory: logger)_get_labextension_dirr   
isinstancelisttuple	TypeErrorr   r   pjoinospathlexistsinfoisdirislinkshutilrmtreeremovemakedirsdirnameabspathexistssymlinkOSErrorplatform
startswith
ValueErrorwalklen_maybe_copy)r#   r/   	overwriter   r   destinationr   r   	full_destlabextmsgeparent_filesdest_dir	file_namesrc	dest_files                      uC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\jupyterlab/federated_labextensions.pydevelop_labextensionrE   .   s   R I"<MF f$u&& Rnx~.v34IRWW__Y//KK*YK0177==##BGGNN9,E,EMM)$IIi  KK	*T:wwt$ww~~i((l9+T$@A


4+> ) 	**K;<CS/! +( ! 
t		RWW__T*B/ "FuYs4y{(;<H77>>(++KK"4XJ ?@H%"	FI.!(I6	C6: # !.  C2=  $$&11)<<{ 
 "#,A-s   L) )
M038M++M0c                    [        U 5      u  px[        R                  R                  UR                  5      S   n	/ n
U H  n[        R                  R                  XS   5      nUS   nU(       a  UR                  SU SU 35        [        R                  R                  U5      (       d	  [        XS9  [        UUUUUUUUS9nU
R                  U5        M     U
$ )zDevelop a labextension bundled in a Python package.

Returns a list of installed/updated directories.

See develop_labextension for parameter information.r   rB   destzInstalling r   r   )r7   r/   r   r   r   r8   r   )_get_labextension_metadatar"   r#   split__file__r   r%   r.   build_labextensionrE   append)moduler   r   r7   r/   r   r   mlabexts	base_path
full_destsr:   rB   rG   r9   s                  rD   develop_labextension_pyrR      s     ,F3JAajj)!,IJggll9Um4f~KK+cU$tf56ww~~c""y8(!/	
	 	)$' *     c                    Uc  [         R                  " [        S5      O![        [	        U5      R                  5       5      n[        [	        U 5      R                  5       5      nU(       a  UR                  SU  35        [        Xe5      nSUSXV/nUb  UR                  SU/5        U(       a  UR                  S5        U(       a  UR                  S5        [        R                  " XS	9  g)
z&Build a labextension in the given pathNstagingBuilding extension in node--core-pathz--static-url--development--source-mapcwd)ospr   HEREstrr   resolver%   _ensure_builderextendrL   
subprocess
check_call)	r#   r   development
static_url
source_map	core_pathext_pathbuilder	argumentss	            rD   rK   rK      s     .7->y)CYH_H_HaDbI4:%%'(H,TF34h2G-EI.*56)()2rS   c                 l   Uc  [         R                  " [        S5      O![        [	        U5      R                  5       5      n[        [	        U 5      R                  5       5      nU(       a  UR                  SU  35        [        U5      n[        [        US5      5       n[        R                  " U5      n	SSS5        W	S   U;  a  [        USS9  O|[        XyS      S   U	S   5      n
[        XiS	   R                  S
S5      5      n[         R                  " U
5      (       d,  [        R                   " U
5        ["        R$                  " X5        ['        Xe5      nSUSUSU/nU(       a  UR)                  S5        U(       a  UR)                  S5        [*        R,                  " XS9  g! , (       d  f       N= f)z$Watch a labextension in a given pathNrU   rV   package.jsonnameT)r   ext_dir
jupyterlab	outputDirstaticrW   rX   z--watchrY   rZ   r[   )r]   r   r^   r_   r   r`   r%   r   openr!   jsonr   rR   getr'   r(   r)   r"   r/   ra   rL   rc   rd   )r#   labextensions_pathr   re   rg   rh   ri   federated_extensionsfidext_datar9   
output_dirrj   rk   s                 rD   watch_labextensionr{      s^    .7->y)CYH_H_HaDbI4:%%'(H,TF34 44FG	eHn-	.#99S> 
/ 33T:./?@KXV\M]^	8l%;%?%?X%VW
zz)$$MM)$JJz-h2G-IxPI)()2' 
/	.s   F%%
F3c           	         [        [        R                  " US5      5       n[        R                  " U5      nSSS5        [        [        R                  " U S5      5       n[        R                  " U5      nSSS5        WS   S   nWR                  S0 5      R                  S5      nU=(       d!    UR                  S0 5      R                  S5      nUc  SU 3n[        U5      eSU;   aN  [        [        R                  " XS5      5       n[        R                  " U5      R                  S5      nSSS5        [        R                  " [        R                  " U S	5      5      (       d  [        R                  " S
/U S9  U n[        R                  " [        R                  " US	SS5      5      (       dq  [        R                  " U5      U:X  a  Sn[        U5      e[        R                  " U5      n[        R                  " [        R                  " US	SS5      5      (       d  Mq  [        XVSSS9n	U	(       d\  [        [        R                  " US	SSS5      5       n[        R                  " U5      R                  S5      nSSS5        [        XVSSS9n	U	(       d  SU SU 3n[        U5      e[        R                  " US	SSSS5      $ ! , (       d  f       GN= f! , (       d  f       GNi= f! , (       d  f       GN= f! , (       d  f       N= f)zIEnsure that we can build the extension and return the builder script pathrm   NdevDependenciesz@jupyterlab/builderdependenciesz:Extensions require a devDependency on @jupyterlab/builder@/r   node_modulesjlpmr[   z@jupyterlabrj   z"Could not find @jupyterlab/builderT)drop_prerelease1drop_prerelease2z, you have a dependency on libzbuild-labextension.js)rs   r]   r   rt   r   ru   r3   r.   rc   rd   r,   r   )
ri   rh   rx   	core_datary   dep_version1dep_version2r;   targetoverlaps
             rD   ra   ra     su    
chhy.1	2cIIcN	 
3	chhx0	1S99S> 
2./0EFL<< 126::;PQL^8<<#C#G#GH]#^LJ<.Yo l#((8>BCs99S>--i8L D::chhx899vhH5 Fjj&.-STT;;v&(6CS/!V$	 jj&.-STT TDG HHV^]I~V
99S>--i8L
  PT
 J<.Xs  uA  tB  Co88y%AX Y 
3	2	1	1 DC$
 
s/   K K&K+&K=
K
K(+
K:=
Lc                 F   [         R                  R                  U5      (       d  g[         R                  " U 5      R                  [         R                  " U5      R                  -
  S:  a  U(       a  UR                  SU 35        gU(       a  UR                  SU 35        g)aE  Should a file be copied, if it doesn't exist, or is newer?

Returns whether the file needs to be updated.

Parameters
----------

src : string
    A path that should exist from which to copy a file
src : string
    A path that might exist to which to copy a file
logger : Jupyter logger [optional]
    Logger instance to use
Tgư>zOut of date: zUp to date: F)r"   r#   r.   statst_mtimewarningr%   rB   rG   r   s      rD   _should_copyr   9  sw     77>>$	wws|rwwt}555< NN]4&12l4&)*rS   c                     [        XUS9(       a5  U(       a  UR                  SU  SU 35        [        R                  " X5        gg)zCopy a file if it needs updating.

Parameters
----------

src : string
    A path that should exist from which to copy a file
src : string
    A path that might exist to which to copy a file
logger : Jupyter logger [optional]
    Logger instance to use
r   z	Copying: r   N)r   r%   r(   copy2r   s      rD   r6   r6   U  s;     Cf-KK)C5TF34S .rS   c                    SU 4SU4SU4SU4/nU VVs/ s H  u  pVU(       d  M  U SU< 3PM     nnn[        U5      S:  a+  SR                  SR                  U5      5      n[        U5      eU (       a  [	        [        5       S	5      n	U	$ U(       a  [	        [        S
   S	5      n	U	$ U(       a  [	        USSS	5      n	U	$ U(       a  Un	U	$ [	        [        S
   S	5      n	U	$ s  snnf )ae  Return the labextension directory specified

Parameters
----------

user : bool [default: False]
    Get the user's .jupyter/labextensions directory
sys_prefix : bool [default: False]
    Get sys.prefix, i.e. ~/.envs/my-env/share/jupyter/labextensions
prefix : str [optional]
    Get custom prefix
labextensions_dir : str [optional]
    Get what you put in
r   prefixr   r   =r   z[cannot specify more than one of user, sys_prefix, prefix, or labextensions_dir, but got: {}z, labextensionsr   sharejupyter)r5   formatr   r   r!   r   r	   r
   )
r   r   r   r   conflictingnvconflicting_setr;   r:   s
             rD   r   r   h  s     
	6	/0	z"	K 1<Aq|!AaU|OA
?akrrIIo&
 s##')?; M 
'*O< M 
vw	?C
 M	 
" M *1-?M! Bs
   CCc           	         [         R                  " U 5      n[         R                  " U5      (       d  SU S3n[        U5      e/ n [        R
                  " U 5      n[        US5      (       a  XDR                  5       4$  Sn[        R                  R                  [        R                  R                  US5      5      (       a_  [        [        R                  R                  US5      S5       n[        U5      nSSS5        WR                  S0 5      R                  S5      nU(       dD   [         R"                  " [$        R&                  S	S
/US9R)                  S5      R+                  5       n [/        U5        SSKJn	Jn
  UR=                  SS5      /nUR?                  U
" U5      5        UR?                  U	" U5      5        U H>  n [        R
                  " U5      n[        US5      (       a  XDR                  5       4s  $ M@     SU  SU 3n[A        U5      e! [         a  nUR                  U5         SnAGNSnAff = f! , (       d  f       GNP= f! [         R,                   a    SU  S3n[        U5      Sef = f! [0         aN    [         R2                  " [$        R&                  SSSSU/5        [$        R                  R5                  SU5         GN\f = f! [         a  nUR                  U5         SnAGM7  SnAff = f)a>  Get the list of labextension paths associated with a Python module.

Returns a tuple of (the module path,             [{
    'src': 'mockextension',
    'dest': '_mockdestination'
}])

Parameters
----------

module : str
    Importable Python module exposing the
    magic-named `_jupyter_labextension_paths` function
z
The path `z` does not exist._jupyter_labextension_pathsNzpyproject.tomlrbprojectrn   zsetup.pyz--namer[   utf8zThe Python package `z<` is not a valid package, it is missing the `setup.py` file.z-mpipinstallz-er   )find_namespace_packagesfind_packages-r>   zThere is no labextension at z. Errors encountered: )!r]   r-   r.   FileNotFoundError	importlibimport_modulehasattrr   	ExceptionrL   r"   r#   r   rs   r   ru   rc   check_outputsys
executabledecodestripCalledProcessErrorr   r   rd   insert
setuptoolsr   r   replacerb   ModuleNotFoundError)rM   mod_pathr;   errorsrN   excpackagerx   datar   r   package_candidatess               rD   rH   rH     s    {{6"H::h8*$56$$F##F+134433555 5 G 
ww~~bggll8-=>??"'',,x)9:DAS9D B((9b)--f5 	3''^^Z:    %
 B 	S! mH56) &	''0Aq78877999 9 & )0Fvh
OC
c
""q  c BA ,, 	3&vh /5 5  $C(d2	3   %s~~tUItXVW8$%&  	MM#	s\   7H -I*AI .I> 7K
H?#H::H?
I'I;>AKK
L #K;;L )TFFNNNF)FFTTNN)NFNFN)NFFN)N)FFNN)4__doc__r   rt   r"   os.pathr#   r]   r1   r(   rc   r   pathlibr   importlib.metadatar   r   ImportErrorimportlib_metadatar   r   r   r!   jupyter_core.pathsr	   r
   r   jupyter_core.utilsr   (jupyter_server.extension.serverextensionr   jupyterlab_server.configr   tomllibr   tomlicommandsr   objectDEPRECATED_ARGUMENTr-   r,   rJ   r^   rE   rR   rK   r{   ra   r   r6   r   rH    rS   rD   <module>r      s   E
   	     
 A@ ' ! V V 0 E = $h 
{{3;;x() 	i\ 
(X X\32 [_ 3P1h8 &%PS#}  A@@A  s#   C C! CC!C0/C0