
    ^ht                         S 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
Jr  SSKJr  SSKJr  SSKJr  S	S
KJr  S r " S S\5      rS\" 5       -  \4/rg)z'Tornado handler for bundling notebooks.    N)nbclassic_path)import_item)webgen)url2path)JupyterHandler)ConfigManager   toolsc                 2   [         R                  " U 5      (       a  [        R                  " U 5      $ [	        U [
        R                  R                  5      (       a  [        R                  " U 5      $ [        R                  " 5       nUR                  U 5        U$ )zlLike tornado's deprecated gen.maybe_future

but more compatible with asyncio for recent versions
of tornado
)
inspectisawaitableasyncioensure_future
isinstance
concurrentfuturesFuturewrap_future
set_result)objfs     T/home/james-whalen/.local/lib/python3.13/site-packages/nbclassic/bundler/handlers.pymaybe_futurer      so     3$$S))	C++22	3	3""3'' NN	S    c                   b    \ rS rSrS rS r\R                  \R                  S 5       5       r
Srg)BundlerHandler'   c                     [         U l         g)zvMake tools module available on the handler instance for compatibility
with existing bundler API and ease of reference.Nr   )selfs    r   
initializeBundlerHandler.initialize(   s     
r   c                 ^    [        5       nUR                  S5      R                  S0 5      U   $ )a;  
Get bundler metadata from config given a bundler ID.

Parameters
----------
bundler_id: str
    Unique bundler ID within the notebook/bundlerextensions config section

Returns
-------
dict
    Bundler metadata with label, group, and module_name attributes


Raises
------
KeyError
    If the bundler ID is unknown
notebookbundlerextensions)r	   get)r!   
bundler_idcms      r   get_bundlerBundlerHandler.get_bundler-   s-    ( _vvj!%%&92>zJJr   c              #     #    U R                  S5      nU R                  R                  [        U5      S9n U R	                  U5      nUS   n [        U5      n [        U5      n[        UR                  X5      5      v   g! [
         a   n[        R                  " SSU-  5      UeSnAff = f! [         a    UR                  S5      n Nsf = f! [         a   n[        R                  " SS	U-  5      UeSnAff = f7f)
zBundle the given nbclassic.

Parameters
----------
path: str
    Path to the notebook (path parameter)
bundler: str
    Bundler ID to use (query parameter)
bundler)pathi  zBundler %s not enabledNmodule_namezutf-8i  zCould not import bundler %s )get_query_argumentcontents_managerr'   r   r*   KeyErrorr   	HTTPErrorstrUnicodeEncodeErrorencoder   ImportErrorr   bundle)r!   r.   r(   modelr-   er/   bundler_mods           r   r'   BundlerHandler.getD   s     ,,Y7
%%))x~)>	3&&z2G
 m,	6k*K
	3%k2K ;--d:;;)  	3--%= *&+ ,123	3 " 	6%,,W5K	6  	3--%C *&+ ,123	3sj   4C=B C=B/ C %C=
B,B''B,,C=/C
C=CC=
C:C55C::C=r   N)__name__
__module____qualname____firstlineno__r"   r*   r   authenticatedr   	coroutiner'   __static_attributes__ r   r   r   r   '   s3    
K. 	]]#<  #<r   r   z%s/bundle/(.*))__doc__r   r   concurrent.futuresr   	nbclassicr   traitlets.utils.importstringr   tornador   r   jupyter_server.utilsr   jupyter_server.base.handlersr   jupyter_server.services.configr	    r   r   r   default_handlersrD   r   r   <module>rO      sV    -
    $ 4  ) 7 8 "B<^ B<L ))>: r   