
    ^h(                       % 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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Jr  SS	KJr  S
SKJrJrJrJrJrJrJr  S
SK J!r!J"r"  0 r#S\$S'   \%" \RL                  \'5      (       a  \#RQ                  \RL                  5        SSS.r)\#RQ                  \)5        0 r*S\$S'   \%" \RV                  \'5      (       a  \*RQ                  \RV                  5        SS\RX                  00S4SSS00S4SSS00S4S.r-S\$S'   \*RQ                  \-5         " S S\.5      r/ " S  S\5      r0 " S! S"\05      r1\2S#:X  a  \0Rg                  5         gg)$zh
A base Application class for Jupyter applications.

All Jupyter applications should inherit from this.
    )annotationsN)deepcopy)Path)which)BoolListUnicodeobserve)Applicationcatch_config_error)ConfigFileNotFound   )allow_insecure_writesissue_insecure_write_warningjupyter_config_dirjupyter_config_pathjupyter_data_dirjupyter_pathjupyter_runtime_dir)ensure_dir_existsensure_event_loopzdict[str, t.Any]base_aliaseszApplication.log_levelzJupyterApp.config_file)z	log-levelconfig
base_flagsr   	log_levelz8set log level to logging.DEBUG (maximize logging output)
JupyterAppgenerate_configTzgenerate default config file
answer_yesz1Answer yes to any questions instead of prompting.)debugzgenerate-configy_jupyter_flagsc                      \ rS rSrSrSrg)NoStartB   z6Exception to raise when an application shouldn't start N)__name__
__module____qualname____firstlineno____doc____static_attributes__r%       R/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_core/application.pyr#   r#   B   s    @r,   r#   c                    ^  \ rS rSrSrSrSr\r\	r
SS jr\" \" 5       5      rSS jr\" 5       rS S jr\SS j5       r\" 5       rS S	 jr\" 5       rS S
 jr\" S5      S!S j5       r\" SSSS9r\" SSS9rS S jr\" SSS9r\" SSSS9rS"S jr S"S jr!S#S$U 4S jjjr"S%S jr#\S&S j5       r$\" 5       r%\&S'S(S jj5       r'S"S jr(\)S'S)U 4S jjj5       r*Sr+U =r,$ )*r   F   z#Base class for Jupyter applicationsjupyterzA Jupyter Applicationc                "    [         R                  $ N)loggingINFOselfs    r-   _log_level_defaultJupyterApp._log_level_defaultO   s    ||r,   c                    [        5       $ r2   )r   r5   s    r-   _jupyter_path_default JupyterApp._jupyter_path_defaultT   s
    ~r,   c                    [        5       $ r2   )r   r5   s    r-   _config_dir_defaultJupyterApp._config_dir_defaultY   s    !##r,   c                r    [        5       nU R                  U;  a  UR                  SU R                  5        U$ )Nr   )r   
config_dirinsert)r6   paths     r-   config_file_pathsJupyterApp.config_file_paths\   s-    "$??$&KK4??+r,   c                .    [        5       n[        USS9  U$ N  mode)r   r   )r6   ds     r-   _data_dir_defaultJupyterApp._data_dir_defaultf   s    !%(r,   c                .    [        5       n[        USS9  U$ rF   )r   r   )r6   rds     r-   _runtime_dir_defaultJupyterApp._runtime_dir_defaultm   s     ""5)	r,   runtime_dirc                    [        US   SS9  g )NnewrG   rH   )r   )r6   changes     r-   _runtime_dir_changedJupyterApp._runtime_dir_changedr   s    &-e4r,   FTzGenerate default config file.)r   helpzSpecify a config file to load.c                d    U R                   (       d  gU R                   R                  SS5      S-   $ )N -__config)namereplacer5   s    r-   _config_file_name_default$JupyterApp._config_file_name_defaultz   s(    yyyy  c*Y66r,   zFull path of a config file.zAnswer yes to any prompts.c                  ^ U R                   (       a  U R                   mO,[        [        U R                  U R                  S-   5      5      m[        T5      R                  5       (       ay  U R                  (       dh  SnSU4S jjnU" 5       nUR                  S5      (       d*  [        S5        U" 5       nUR                  S5      (       d  M*  UR                  S5      (       a  gU R                  5       n[        S5        [        [        T5      R                  R                  5       S	5        [        R                  " [        T5      S
SS9 nUR                  U5        SSS5        g! , (       d  f       g= f)z-Write our default config to a .py config filez.pyrY   c                    > ST< S3n  [        U 5      R                  5       =(       d    S$ ! [         a    [        S5         gf = f)Nz
Overwrite z with default config? [y/N]nrY   )inputlowerKeyboardInterruptprint)promptconfig_files    r-   ask,JupyterApp.write_default_config.<locals>.ask   sH    %k_4OP =..07C7( "Is   !, AA)r    rc   zPlease answer 'yes' or 'no'rc   Nz*Writing default config to: {config_file!r}rG   wzutf-8)rI   encodingreturnstr)ri   rp   r   r@   config_file_nameexistsr   
startswithrg   generate_config_filer   parentresolveopenwrite)r6   answerrj   config_textfri   s        @r-   write_default_configJupyterApp.write_default_config   s    **Kd4??D4I4IE4QRSK##%%dooF UF''
3334 ''
33   %%//1:;${+22::<eDYYtK(sWEGGK  FEEs   
E%%
E3c                    [         R                  " [        U R                  S5      S5      nUR                  5         g! [         a     O[
         a     gf = fSSKJnJn  [        U" 5       5      R                  5       (       d  gU" 5         g)z"Migrate config/data from IPython 3migratedzr+Nr   )get_ipython_dirmigrate)	r   rw   r@   closeFileNotFoundErrorOSErrorr   r   rr   )r6   f_markerr   r   s       r-   migrate_configJupyterApp.migrate_config   sv    
	yydooz!BDIH NN ! 	 		 	6 O%&--//	s   +> 
A
	AAc                  > U R                   R                  SU R                  5        Sn [        TU ]  UU R                  S9  U R                  (       a,  [        R                  R                  U R                  5      u  p4O%U R                  nU R                  nU(       a  XB:X  a  g [        TU ]  XCS9  g! [
         a    U R                   R                  SU5         Nf = f! [
         a    U R                   R                  SU5         g[         a7    U(       a  U R                  (       a  e U R                   R                  SUSS	9   gf = f)
zLoad the config file.

By default, errors in loading config are handled, and a warning
printed on screen. For testing, the suppress_errors option is set
to False, so errors will make tests fail.
zSearching %s for config filesjupyter_config)rB   zConfig file %s not foundNz#Config file not found, skipping: %szError loading config file: %sT)exc_info)logr   rC   superload_config_filer   ri   osrB   splitrq   	Exceptionraise_config_file_errorswarning)r6   suppress_errorsbase_configrB   rq   	__class__s        r-   r   JupyterApp.load_config_file   s+    	68N8NO&	DG$++ %  %'WW]]43C3C%D"D"))D#44#(8(G		_G$%5$A " 	DHHNN5{C	D " 	THHNN@BRS 	_ $(E(EHH<>NY]^	_s)   B4 &C  4&CC &E=EEc                L    U R                    SU 3n[        U5      =(       d    S$ )NrZ   rY   )r]   r   )r6   r]   s     r-   _find_subcommandJupyterApp._find_subcommand   s%    ))AdV$T{ b r,   c                x    [        U R                  =(       d    U R                  =(       d    U R                  5      $ )zLReturn whether we are dispatching to another command

or running ourselves.
)boolr   subapp
subcommandr5   s    r-   _dispatchingJupyterApp._dispatching   s'     D((JDKKJ4??KKr,   c                   Uc  [         R                  SS nU(       a(  U R                  US   5      nU(       a  Xl        X l        gU R	                  U5        [        U R                  5      nU R                  (       a  gU R                  5         U R                  5         U R                  U5        [        (       a  [        5         gg)zInitialize the application.Nr   r   )sysargvr   r   parse_command_liner   r   r   r   r   update_configr   r   )r6   r   subc	cl_configs       r-   
initializeJupyterApp.initialize   s     <88AB<D((a1D 	"&%T[[)	9%  (* !r,   c                r   U R                   (       aF  [        R                  " U R                   U R                   /U R                  SS -   5        [	        5       eU R
                  (       a$  U R
                  R                  5         [	        5       eU R                  (       a  U R                  5         [	        5       eg)zStart the whole thingr   N)	r   r   execvr   r#   r   startr   r|   r5   s    r-   r   JupyterApp.start  sw    ??HHT__t&7$))AB-&GH)O;;KK)O%%')O  r,   c                   > [        5       n [        TU ]  " SSU0UD6  UR	                  5         g! [         a     gf = f)z+Launch an instance of a Jupyter Applicationr   Nr%   )r   r   launch_instancer#   r   )clsr   kwargsloopr   s       r-   r   JupyterApp.launch_instance  sF     !"	G#888 	

  		s   0 
==)r   r   )ro   int)ro   z	list[str]rn   )rT   t.Anyro   Nonero   r   )T)r   r   ro   r   )r]   rp   ro   rp   )ro   r   r2   r   r   ro   r   r   r   r   r   ro   r   )-r&   r'   r(   r)   r*   r]   descriptionr   aliasesr   flagsr7   r   r	   r   r:   r@   r=   propertyrC   data_dirrK   rQ   rO   r
   rU   r   r   rq   r_   ri   r   r|   r   r   r   r   r   r   r   r   classmethodr   r+   __classcell__)r   s   @r-   r   r   F   s;   -D)KGE 	?L J$   yH
 )K
 ]5 5 54WXOd1QR7
 .K
 eD/OPJ!@,$_ $_N! L L J+ +,   r,   c                  l    \ rS rSrSrSrSrSrSSS jjrSS jr	\
SSS	 jj5       r\
SSS
 jj5       rSrg)JupyterAsyncAppi"  z3A Jupyter application that runs on an asyncio loop.jupyter_asynczAn Async Jupyter ApplicationFNc                   #    g7f)z+Initialize the application asynchronoously.Nr%   )r6   r   s     r-   initialize_async JupyterAsyncApp.initialize_async+          c                   #    g7f)z%Run the application in an event loop.Nr%   r5   s    r-   start_asyncJupyterAsyncApp.start_async.  r   r   c                   #    U R                   " S0 UD6nUR                  U5        UR                  U5      I S h  vN   UR                  5       I S h  vN   g  N N7f)Nr%   )instancer   r   r   )r   r   r   apps       r-   _launch_instance JupyterAsyncApp._launch_instance1  sN     ll$V$t""4(((oo 	)s!   8AAAAAAc                    [        U R                  5      nU R                  " U40 UD6nUR                  U5        UR	                  5         g)z2Launch an instance of an async Jupyter ApplicationN)r   _prefer_selector_loopr   run_until_completer   )r   r   r   r   coros        r-   r   JupyterAsyncApp.launch_instance8  s@     !!:!:;##D3F3%

r,   r%   r2   r   r   r   )r&   r'   r(   r)   r*   r]   r   r   r   r   r   r   r   r+   r%   r,   r-   r   r   "  sI    =D0K ":4      r,   r   __main__)4r*   
__future__r   r3   r   r   typingtcopyr   pathlibr   shutilr   	traitletsr   r   r	   r
   traitlets.config.applicationr   r   traitlets.config.loaderr   pathsr   r   r   r   r   r   r   utilsr   r   r   __annotations__
isinstancer   dictupdate_jupyter_aliasesr   r   DEBUGr!   r   r#   r   r   r&   r   r%   r,   r-   <module>r      sr   #  	 
     2 2 H 6   8 "$ #k!!4((++,(&    $ %!
 !k&&k''( 
gmm45B &(94'@ACab	d+,;

$  
   . !Ai AY Yxj > z  r,   