
    Mh-                         d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ dd	lmZ d
 Zd Zd Zd Zd Zd Zd Zd ZdZ G d d          ZdS )    )wraps)deepcopy)
TraitError)Config)
JupyterApp)	ServerApp)ExtensionApp   )NotebookAppTraitsc                 .    d                     |           S )Nz'{trait_name}' was found in both NotebookApp and ServerApp. This is likely a recent change. This config will only be set in NotebookApp. Please check if you should also config these traits in ServerApp for your purpose.
trait_nameformatr   s    R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/notebook_shim/shim.pyNBAPP_AND_SVAPP_SHIM_MSGr      s%    " #)& #) # #+    c                 .    d                     |           S )Nz'{trait_name}' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.r   r   r   s    r   NBAPP_TO_SVAPP_SHIM_MSGr      s%        	*r   c                 0    d                     | |          S )Nz'{trait_name}' is found in {extapp_name}, NotebookApp, and ServerApp. This is a recent change. This config will only be set in {extapp_name}. Please check if you should also config these traits in NotebookApp and ServerApp for your purpose.r   extapp_namer   r   s     r   #EXTAPP_AND_NBAPP_AND_SVAPP_SHIM_MSGr   "   s)    2 39& 39 3 3	Cr   c                 0    d                     | |          S )Nz'{trait_name}' is found in both {extapp_name} and ServerApp. This is a recent change. This config will only be set in {extapp_name}. Please check if you should also config these traits in ServerApp for your purpose.r   r   r   s     r   EXTAPP_AND_SVAPP_SHIM_MSGr   .   s(    " #)& #) # #	9r   c                 0    d                     | |          S )Nz'{trait_name}' is found in both {extapp_name} and NotebookApp. This is a recent change. This config will only be set in {extapp_name}. Please check if you should also config these traits in NotebookApp for your purpose.r   r   r   s     r   EXTAPP_AND_NBAPP_SHIM_MSGr   :   s(    $ %+F %+ % %	9r   c                 0    d                     | |          S )Na  '{trait_name}' is not found in {extapp_name}, but it was found in both NotebookApp and ServerApp. This is likely a recent change. This config will only be set in ServerApp. Please check if you should also config these traits in NotebookApp for your purpose.r   r   r   s     r   #NOT_EXTAPP_NBAPP_AND_SVAPP_SHIM_MSGr   F   s)    $
 %+F %+ % %
Cr   c                 0    d                     | |          S )Nzp'{trait_name}' has moved from {extapp_name} to ServerApp. Be sure to update your config before our next release.r   r   r   s     r   EXTAPP_TO_SVAPP_SHIM_MSGr!   S   &       8r   c                 0    d                     | |          S )Nzr'{trait_name}' has moved from {extapp_name} to NotebookApp. Be sure to update your config before our next release.r   r   r   s     r   EXTAPP_TO_NBAPP_SHIM_MSGr$   ]   r"   r   )open_browser	log_level
log_formatdefault_urlshow_bannerc                   T     e Zd ZdZ eej                   fd            Zd Z xZS )NotebookConfigShimMixina  A Mixin class for shimming configuration from
    NotebookApp to ServerApp. This class handles warnings, errors,
    etc.

    This class should be used during a transition period for apps
    that are switching from depending on NotebookApp to ServerApp.

    After one release cycle, this class can be safely removed
    from the inheriting class.

    TL;DR

    The entry point to shimming is at the `update_config` method.
    Once traits are loaded, before updating config across all
    configurable objects, this class injects a method to reroute
    traits to their *most logical* classes.

    This class raises warnings when:
        1. a trait has moved.
        2. a trait is redundant across classes.

    Redundant traits across multiple classes now must be
    configured separately, *or* removed from their old
    location to avoid this warning.

    For a longer description on how individual traits are handled,
    read the docstring under `shim_config_from_notebook_to_jupyter_server`.
    c                 t    |                      |          }t                                          |           d S )N)+shim_config_from_notebook_to_jupyter_serversuperupdate_config)selfconfigshimmed_config	__class__s      r   r/   z%NotebookConfigShimMixin.update_config   s;     II n-----r   c                    | j         j        }|                    di           }|                    di           }|                    |i           }t          |          }i }i }i }	| j                                         t          j                    z   }
t          j                    }t          j                    t          j                    z   }|                    |           d}|	                                D ]\  }}||v }||v }|t          v r|                    ||i           n|r)|r't          |          }|                    ||i           ne|r't          |          }|                    ||i           n<|r|                    ||i           n"t          d                    |                    |r| j                            |           d}|	                                D ]\  }}||
v }||v }||v }|t          v r|	                    ||i           nOt#          |||g          r)t%          ||          }|	                    ||i           n|r*|r(t'          ||          }|	                    ||i           n|r*|r(t)          ||          }|	                    ||i           n|r|	                    ||i           n|r*|r(t+          ||          }|                    ||i           nv|r(t-          ||          }|                    ||i           nL|r(t/          ||          }|                    ||i           n"t          d                    |                    |r| j                            |           t1          ||d          }|	r.|                    t1          | j         j        |	i                     |                    |           |S )u  Reorganizes a config object to reroute traits to their expected destinations
        after the transition from NotebookApp to ServerApp.

        A detailed explanation of how traits are handled:

        1. If the argument is prefixed with `ServerApp`,
            pass this trait to `ServerApp`.
        2. If the argument is prefixed with `NotebookApp`,
            * If the argument is a trait of `NotebookApp` *and* `ServerApp`:
                1. Raise a warning—**for the extension developers**—that
                    there's redundant traits.
                2. Pass trait to `NotebookApp`.
            * If the argument is a trait of just `ServerApp` only
                (i.e. the trait moved from `NotebookApp` to `ServerApp`):
                1. Raise a "this trait has moved" **for the user**.
                3. Pass trait to `ServerApp`.
            * If the argument is a trait of `NotebookApp` only, pass trait
                to `NotebookApp`.
            * If the argument is not found in any object, raise a
                `"Trait not found."` error.
        3. If the argument is prefixed with `ExtensionApp`:
            * If the argument is a trait of `ExtensionApp`,
                `NotebookApp`, and `ServerApp`,
                1. Raise a warning about redundancy.
                2. Pass to the ExtensionApp
            * If the argument is a trait of `ExtensionApp` and `NotebookApp`,
                1. Raise a warning about redundancy.
                2. Pass to ExtensionApp.
            * If the argument is a trait of `ExtensionApp` and `ServerApp`,
                1. Raise a warning about redundancy.
                2. Pass to ExtensionApp.
            * If the argument is a trait of `ExtensionApp`.
                1. Pass to ExtensionApp.
            * If the argument is a trait of `NotebookApp` but not `ExtensionApp`,
                1. Raise a warning that trait has likely moved to NotebookApp.
                2. Pass to NotebookApp
            * If the arguent is a trait of `ServerApp` but not `ExtensionApp`,
                1. Raise a warning that the trait has likely moved to ServerApp.
                2. Pass to ServerApp.
            * else
                * Raise a TraitError: "trait not found."
        NotebookAppr   NzTrait, {}, not found.)r5   r   )r3   __name__popr   class_trait_namesr	   r   r   updateitemsIGNORED_TRAITSr   r   r   r   logwarningallr   r   r   r   r!   r$   r   )r0   r1   r   nbapp_configsvapp_configextapp_configconfig_shimsvapp_config_shimnbapp_config_shimextapp_config_shimextapp_traitssvapp_traitsnbapp_traitswarning_msgr   trait_valuein_svappin_nbapp	in_extapp
new_configs                       r   r-   zCNotebookConfigShimMixin.shim_config_from_notebook_to_jupyter_server   s   V n- zz-44zz+r22

;33 v&& N,,..*,,- 	 !244/11*,,- 	 	  ... '3'9'9';'; 	. 	.#J!\1H!\1H^++!((*k)BCCCC 	Mh 	M6zBB!((*k)BCCCC M5jAA!((*k)BCCCC M!((*k)BCCCC !8!?!?
!K!KLLL  .  --- '4':':'<'< 2	. 2	.#J"m3I!\1H!\1H^++")):{*CDDDDi8455 'MA  #)):{*CDDDD !Mx !M7  #)):{*CDDDD Mx M7  #)):{*CDDDD M")):{*CDDDD Mh MA  "((*k)BCCCC M6  "((*k)BCCCC M6  "((*k)BCCCC !8!?!?
!K!KLLL  .  --- ,*
 
  
  	f');&      	:&&&r   )	r6   
__module____qualname____doc__r   r   r/   r-   __classcell__)r3   s   @r   r+   r+   l   sr         : U:#$$. . . . %$.^ ^ ^ ^ ^ ^ ^r   r+   N)	functoolsr   copyr   	traitletsr   traitlets.config.loaderr   jupyter_core.applicationr   jupyter_server.serverappr   $jupyter_server.extension.applicationr	   traitsr   r   r   r   r   r   r   r!   r$   r;   r+    r   r   <module>r\      s_                                0 / / / / / . . . . . . = = = = = = % % % % % %    	 	 		 	 		 	 	
 
 
     [C C C C C C C C C Cr   