
    FhW4                       S 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rSSK	r	SSK
Jr  SSKJr  SSKJr  SSKJrJrJr  SSKJrJrJr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&J'r'J(r(J)r)  SSK*J+r+  \(       a  SSK,J-r-J.r.  \" S\/5      r0\r\r\"r!S+S jr1S,S jr2S-S jr3S.S jr4S-S jr5S-S jr6S/S jr7S0S1S jjr8S0S2S jjr9S3S jr:S4S jr;S4S jr<\Rz                  S:X  a  \;r>O\<r>S r?S5S jr@S5S  jrAS5S! jrBS6S" jrC\ S7         S8S# jj5       rD S7         S9S$ jjrE S:           S;S% jjrFS<S& jrGS=S' jrHS>S( jrI " S) S*\J5      rKg)?zNotebook related utilities    )annotationsN)_NamespacePath)contextmanager)Path)TYPE_CHECKINGAnyNewType)SplitResultquoteunquoteurlparseurlsplit
urlunsplit)urljoin)pathname2url)ensure_async)Version)AsyncHTTPClient
HTTPClientHTTPRequestHTTPResponse)Resolver)	GeneratorSequenceApiPathc                    U S   R                  S5      nU S   R                  S5      nU  Vs/ s H  o3R                  S5      PM     nnSR                  S U 5       5      nU(       a  SU-   nU(       a  US-   nUS:X  a  SnU$ s  snf )zJoin components of url into a relative url

Use to prevent double slash when joining subpath. This will leave the
initial and final / in place
r   /c              3  6   #    U  H  o(       d  M  Uv   M     g 7fN ).0ss     gC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\jupyter_server/utils.py	<genexpr> url_path_join.<locals>.<genexpr>7   s     /AQaas   
	z//)
startswithendswithstripjoin)piecesinitialfinalr#   strippedresults         r$   url_path_joinr0   .   s     Qi""3'G2J$E&,-ffH-XX///Fv#~M .s   Bc                J    [        U 5      R                  R                  S5      $ )z)Determine whether a given URL is absoluter   )r   pathr'   )urls    r$   url_is_absoluter4   A   s    C=((--    c                    U R                  [        R                  5       Vs/ s H  n[        U5      PM     nnUS   S:X  a  SUS'   [	        U6 nU$ s  snf )z"Convert a local file path to a URLr    r   )splitossepr   r0   )r2   pr+   r3   s       r$   path2urlr<   F   sR     $

266 23 21eAh 2F3bzRr


 CJ 4s   Ac                    U R                  S5       Vs/ s H  n[        U5      PM     nn[        R                  R                  " U6 nU$ s  snf )z"Convert a URL to a local file pathr   )r8   r   r9   r2   r*   )r3   r;   r+   r2   s       r$   url2pathr>   P   s>    "%))C.1.Qgaj.F177<< DK 2s   A
c                    U R                  S5      nSR                  U Vs/ s H  n[        U5      PM     sn5      $ s  snf )zNEscape special characters in a URL path

Turns '/foo bar/' into '/foo%20bar/'
r   )r8   r*   r   )r2   partsr;   s      r$   
url_escaperA   W   s6    
 JJsOE88u-u!U1Xu-..-s   =c                    SR                  U R                  S5       Vs/ s H  n[        U5      PM     sn5      $ s  snf )zPUnescape special characters in a URL path

Turns '/foo%20bar/' into '/foo bar/'
r   )r*   r8   r   )r2   r;   s     r$   url_unescaperC   `   s1    
 88C9AWQZ9::9s   ;c                    [         R                  " U 5      n[         R                  " U5      nU R                  5       UR                  5       :H  =(       a    X#:H  $ )a0  
Fill in for os.path.samefile when it is unavailable (Windows+py2).

Do a case-insensitive string comparison in this case
plus comparing the full stat result (including times)
because Windows + py2 doesn't support the stat fields
needed for identifying if it's the same file (st_ino, st_dev).

Only to be used if os.path.samefile is not available.

Parameters
----------
path : str
    representing a path to a file
other_path : str
    representing a path to another file

Returns
-------
same:   Boolean that is True if both path and other path are the same
)r9   statlower)r2   
other_path	path_statother_path_stats       r$   samefile_simplerJ   h   sA    , Iggj)O::<:++--N)2NNr5   c                   [        U 5      R                  S5      R                  S5      nU Vs/ s H  o3S:w  d  M
  UPM     nn[        R                  R
                  " U/UQ76 n[        R                  R                  U5      $ s  snf )zConvert an API path to a filesystem path

If given, root will be prepended to the path.
root must be a filesystem path already.
r   r7   )strr)   r8   r9   r2   r*   normpath)r2   rootr@   r;   path_s        r$   
to_os_pathrP      sj     IOOC &&s+E)1bQE)GGLL&&E77E"" *s
   	BBc                ^   U R                  U5      (       a  U [        U5      S n U R                  [        R                  R
                  5      R                  [        R                  R
                  5      nU Vs/ s H  o3S:w  d  M
  UPM     nnSR                  U5      n[        U5      $ s  snf )zConvert a filesystem path to an API path

If given, root will be removed from the path.
root must be a filesystem path already.
Nr7   r   )	r'   lenr)   r9   r2   r:   r8   r*   r   )os_pathrN   r@   r;   r2   s        r$   to_api_pathrT      s     $#d)+&MM"''++&,,RWW[[9E)1bQE)88E?D4= *s   9	B*B*c                d     [        [        U 5      [        U5      :  5      $ ! [         a     gf = f)zcheck version string v >= check

If dev/prerelease tags result in TypeError for string-number comparison,
it is assumed that the dependency is satisfied.
Users on dev branches are responsible for keeping their own packages up to date.
T)boolr   	TypeError)vchecks     r$   check_versionrZ      s1    GAJ'%.011 s   " 
//c                j    SS K n[        UR                  R                  R	                  SSU 5      5      $ )Nr      )ctypesrV   windllkernel32OpenProcess)pidr]   s     r$   _check_pid_win32rb      s+     &&221a=>>r5   c                     [         R                  " U S5        g! [         aL  nUR                  [        R                  :X  a   SnAgUR                  [        R
                  :X  a   SnAge SnAff = f)z'Copy of IPython.utils.process.check_pidr   TNF)r9   killOSErrorerrnoESRCHEPERM)ra   errs     r$   _check_pid_posixrj      sT    

Q   99#YY%++%s     
A0A+A+*A++A0win32c                T   #    [         R                  " S[        SS9  [        U 5      $ 7f)z?**DEPRECATED**: Use ``ensure_async`` from jupyter_core instead.zerun_sync_in_loop is deprecated since Jupyter Server 2.0, use 'ensure_async' from jupyter_core instead   )
stacklevel)warningswarnDeprecationWarningr   )maybe_asyncs    r$   run_sync_in_looprs      s'     MMo
 $$s   &(c                &    U R                  SS5      $ )zREncodes a UNIX socket path string from a socket path for the `http+unix` URI form.r   %2Freplacesocket_paths    r$   urlencode_unix_socket_pathrz      s    sE**r5   c                &    U R                  SS5      $ )zWDecodes a UNIX sock path string from an encoded sock path for the `http+unix` URI form.ru   r   rv   rx   s    r$   urldecode_unix_socket_pathr|      s    uc**r5   c                    S[        U 5      -  $ )zJEncodes a UNIX socket URL from a socket path for the `http+unix` URI form.zhttp+unix://%s)rz   rx   s    r$   urlencode_unix_socketr~      s    8EEEr5   c                d   [         R                  R                  U 5      (       d  g [        R                  " [        R                  [        R
                  5      nUR                  U 5         UR                  5         g! [         a     WR                  5         gf = f! WR                  5         f = f)zSChecks whether a UNIX socket path on disk is in use by attempting to connect to it.FT)	r9   r2   existssocketAF_UNIXSOCK_STREAMconnectclosere   )ry   socks     r$   unix_socket_in_user      s|    77>>+&&}}V^^V-?-?@[! 

   	


 	

s$   AA= =
BB BB B/c              #    #    [        U 5      nUR                  S;   a  OUR                  S:X  ah  [        SUR                  UR                  UR
                  UR                  S9n " S S[        5      nU" [        5       S9n[        R                  " SUS9  OS	n[        U5      e[        U5      n[        XX#S
S9n	U	v   g7f)a2  A utility that provides a context that handles
HTTP, HTTPS, and HTTP+UNIX request.
Creates a tornado HTTPRequest object with a URL
that tornado's HTTPClients can accept.
If the request is made to a unix socket, temporarily
configure the AsyncHTTPClient to resolve the URL
and connect to the proper socket.
)httphttpsz	http+unixr   )schemenetlocr2   queryfragmentc                  *    \ rS rSrSrS rS rS rSrg)7_request_for_tornado_client.<locals>.UnixSocketResolveri  a  A resolver that routes HTTP requests to unix sockets
in tornado HTTP clients.
Due to constraints in Tornados' API, the scheme of the
must be `http` (not `http+unix`). Applications should replace
the scheme in URLS before making a request to the HTTP client.
c                    Xl         g r    resolver)selfr   s     r$   
initializeB_request_for_tornado_client.<locals>.UnixSocketResolver.initialize  s     (r5   c                8    U R                   R                  5         g r    )r   r   )r   s    r$   r   =_request_for_tornado_client.<locals>.UnixSocketResolver.close  s    ##%r5   c                B   #    [         R                  [        U5      4/$ 7fr    )r   r   r|   )r   hostportargskwargss        r$   resolve?_request_for_tornado_client.<locals>.UnixSocketResolver.resolve  s     )CD)IJKKs   r   N)	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__r!   r5   r$   UnixSocketResolverr     s    )&Lr5   r   r   NzUnknown URL scheme.F)methodbodyheadersvalidate_cert)r   r   r
   r   r2   r   r   r   r   	configure	Exceptionr   r   )
	urlstringr   r   r   r@   r   r   msgr3   requests
             r$   _request_for_tornado_clientr      s      YE||((		$<<++^^
	L 	L" &xz:!!$:#n U
C#4X]^G
Ms   B=B?c                    [        XX#S9 n[        [        5      R                  U5      nSSS5        U$ ! , (       d  f       W$ = f)zc
Send a HTTP, HTTPS, or HTTP+UNIX request
to a Tornado Web Server. Returns a tornado HTTPResponse.
r   r   r   N)r   r   r   fetch)r   r   r   r   r   responses         r$   r   r   )  sG     
%t
	o.44W=
 O	
 
 Os	   4
Ac                   #    [        XX#S9 n[        U5      R                  U5      I Sh  vN nSSS5        U$  N! , (       d  f       W$ = f7f)zq
Send an asynchronous HTTP, HTTPS, or HTTP+UNIX request
to a Tornado Web Server. Returns a tornado HTTPResponse.
r   N)r   r   r   )r   r   r   r   io_loopr   r   s          r$   async_fetchr   7  sR      
%t
	(177@@
 O A
 
 Os%   A<:<
A<
AAc                     [         R                  R                  U 5      nU(       d  g[	        UR
                  [        5      $ ! [         a     gf = f)zIs the provided namespace a Python Namespace Package (PEP420).

https://www.python.org/dev/peps/pep-0420/#specification

Returns `None` if module is not importable.

N)	importlibutil	find_spec
ValueError
isinstancesubmodule_search_locationsr   )	namespacespecs     r$   is_namespace_packager   E  sJ    ~~''	2 d55~FF  s   A 
AAc                   [        U 5      nUR                  5       (       a  U  S3n[        U5      eU H  n[        U5      R                  5       nXR-  n[        [        R
                  R                  U5      5      nUR                  U5      (       d  M`  UR                  5       (       d  Mw  [        R
                  R                  U5      s  $    SU < SU< 3n[        U5      e)a  Find a file by looking through a sequence of paths.

For use in FileFindHandler.

Iterates through a sequence of paths looking for a file and returns
the full, absolute path of the first occurrence of the file.

Absolute paths are not accepted for inputs.

This function does not automatically try any paths,
such as the cwd or the user's home directory.

Parameters
----------
filename : str
    The filename to look for. Must be a relative path.
path_dirs : sequence of str
    The sequence of paths to look in for the file.
    Walk through each element and join with ``filename``.
    Only after ensuring the path resolves within the directory is it checked for existence.

Returns
-------
Raises :exc:`OSError` or returns absolute path to file.
z3 is absolute, filefind only accepts relative paths.zFile z, does not exist in any of the search paths: )	r   is_absolutere   absoluter9   r2   abspathis_relative_tois_file)filename	path_dirs	file_pathr   path_strr2   	test_paths          r$   filefindr   Y  s    4 XI 
MNclH~&&($	 34	''-- 77??9--  (I)
WC
#,r5   c                    U R                  SS5      n[        U5      S:X  a  Uu  p#[        X#/S9n [        XC5      nU$ [        US   5      $ ! [         a  n[        SU-  5      UeSnAff = f)aT  Import and return ``bar`` given the string ``foo.bar``.
Calling ``bar = import_item("foo.bar")`` is the functional equivalent of
executing the code ``from foo import bar``.
Parameters
----------
name : str
  The fully qualified name of the module/package being imported.
Returns
-------
mod : module object
   The module that was imported.
.r\   rm   )fromlistzNo module named %sNr   )rsplitrR   
__import__getattrAttributeErrorImportError)namer@   packageobjmodulepakes          r$   import_itemr     s     KKQE
5zQGe4	A&&C 
 %(##  	A2S89q@	As   A 
A*A%%A*c                      \ rS rSrSrSrg)JupyterServerAuthWarningi  zEmitted when authentication configuration issue is detected.

Intended for filtering out expected warnings in tests, including
downstream tests, rather than for users to silence this warning.
r!   N)r   r   r   r   r   r   r!   r5   r$   r   r     s    r5   r   )r+   rL   returnrL   )r3   rL   r   rV   )r2   rL   r   rL   )r3   rL   r   rL   )r2   rL   rG   rL   r   rV   )r7   )r2   r   rN   rL   r   rL   )rS   rL   rN   rL   r   r   )rX   rL   rY   rL   r   rV   )ra   intr   rV   )ry   rL   r   rL   )ry   rL   r   rV   )GETNN)
r   rL   r   rL   r   r   r   r   r   z"Generator[HTTPRequest, None, None])
r   rL   r   rL   r   r   r   r   r   r   )r   NNN)r   rL   r   rL   r   r   r   r   r   r   r   r   )r   rL   r   zbool | None)r   rL   r   zSequence[str]r   rL   )r   rL   r   r   )Lr   
__future__r   rf   importlib.utilr   r9   r   sysro   _frozen_importlib_externalr   
contextlibr   pathlibr   typingr   r   r	   urllib.parser
   r   r   r   r   r   r   _urljoinurllib.requestr   _pathname2urljupyter_core.utilsr   _ensure_asyncpackaging.versionr   tornado.httpclientr   r   r   r   tornado.netutilr   collections.abcr   r   rL   r   r0   r4   r<   r>   rA   rC   rJ   rP   rT   rZ   rb   rj   platform	check_pidrs   rz   r|   r~   r   r   r   r   r   r   r   RuntimeWarningr   r!   r5   r$   <module>r      s     #   	  
  5 %  . .  9 < % U U $3
)S
! &.
/;O6	#
 ? <<7 I I%+
+
F
  JN222/22DG2'2 2l KO/2DG `d/2DGY\G(0f$:~ r5   