
    Fh-                         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	  S SK
Jr  S SKJr  SS	KJr  S
 rS rS rS rS rS rS rS rSr " S S5      rg)    )wraps)deepcopy)
TraitError)Config)
JupyterApp)	ServerApp)ExtensionApp   )NotebookAppTraitsc                      SR                  U S9$ )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    eC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\notebook_shim/shim.pyNBAPP_AND_SVAPP_SHIM_MSGr      s     " #)& #) #+    c                      SR                  U S9$ )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                 "    SR                  U US9$ )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	Cr   c                 "    SR                  U US9$ )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                 "    SR                  U US9$ )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                 "    SR                  U US9$ )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                 "    SR                  U US9$ )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                 "    SR                  U US9$ )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                   \   ^  \ rS rSrSr\" \R                  5      U 4S j5       rS rSr	U =r
$ )NotebookConfigShimMixinl   a  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                 F   > U R                  U5      n[        TU ]	  U5        g )N)+shim_config_from_notebook_to_jupyter_serversuperupdate_config)selfconfigshimmed_config	__class__s      r   r0   %NotebookConfigShimMixin.update_config   s%     IIn-r   c                    U R                   R                  nUR                  S0 5      nUR                  S0 5      nUR                  U0 5      n[        U5      n0 n0 n0 n	U R                   R	                  5       [
        R                  " 5       -   n
[        R                  " 5       n[        R                  " 5       [
        R                  " 5       -   nUR                  U5        SnUR                  5        H  u  pX;   nX;   nU[        ;   a  UR                  X05        OU(       a%  U(       a  [        U5      nUR                  X05        OYU(       a  [        U5      nUR                  X05        O4U(       a  UR                  X05        O[        SR                  U5      5      eU(       d  M  U R                  R!                  U5        M     SnUR                  5        GH  u  pX;   nX;   nX;   nU[        ;   a  U	R                  X05        GO:[#        UUU/5      (       a   [%        UU5      nU	R                  X05        GOU(       a&  U(       a  ['        UU5      nU	R                  X05        OU(       a&  U(       a  [)        UU5      nU	R                  X05        OU(       a  U	R                  X05        OU(       a&  U(       a  [+        UU5      nUR                  X05        OfU(       a  [-        UU5      nUR                  X05        O@U(       a  [/        UU5      nUR                  X05        O[        SR                  U5      5      eU(       d  GMt  U R                  R!                  U5        GM     [1        UUS.5      nU	(       a0  UR                  [1        U R                   R                  U	05      5        UR                  U5        U$ )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.)r7   r   )r4   __name__popr   class_trait_namesr	   r   r   updateitemsIGNORED_TRAITSr   r   r   r   logwarningallr   r   r   r   r!   r$   r   )r1   r2   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.   CNotebookConfigShimMixin.shim_config_from_notebook_to_jupyter_server   s   V nn-- zz-4zz+r2

;3 v& NN,,.**,- 	 !224//1**,- 	 	  . '3'9'9';#J!1H!1H^+!((*)BCh6zB!((*)BC5jA!((*)BC!((*)BC !8!?!?
!KLL {  -' (<, '4':':'<#J"3I!1H!1H^+")):*CDi8455A #)):*CDx7 #)):*CDx7 #)):*CD")):*CDhA "((*)BC6 "((*)BC6 "((*)BC !8!?!?
!KLL {  -e (=j ,*
 
 f'');&   	:&r    )r8   
__module____qualname____firstlineno____doc__r   r   r0   r.   __static_attributes____classcell__)r4   s   @r   r+   r+   l   s3    : :##$. %.^ ^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+   rR   r   r   <module>ra      s]        0 . = %			
 [C Cr   