
    ^hi=                        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	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\R,                  5      rSS jrSS jrSS jrSS jrSS jrSS jrSS jr\S:X  a  \" 5         gg)zgThe root `jupyter` command.

This does nothing other than dispatch to subcommands or output path info.
    )annotationsN)Path)which)Popen)Any   )paths)__version__c                  ^    \ rS rSrSr\SS j5       r\R                  S	S j5       rS
S jrSr	g)JupyterParser   zA Jupyter argument parser.c                >    SR                  [        5       5      nSU 3$ )zmAdd subcommands to epilog on request

Avoids searching PATH for subcommands unless help output is requested.
 zAvailable subcommands: )joinlist_subcommands)selfsubcommandss     N/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_core/command.pyepilogJupyterParser.epilog   s#     88$4$67(66    c                    g)z$Ignore epilog set in Parser.__init__N )r   xs     r   r   r   '   s    r   c                P     SSK nUR                  U 5        g! [         a     gf = f)z#Trigger auto-completion, if enabledr   N)argcompleteautocompleteImportError)r   r   s     r   r   JupyterParser.argcomplete+   s*    	$$T* 		s    
%%r   N)returnstr)r   r   r    Noner    r"   )
__name__
__module____qualname____firstlineno____doc__propertyr   setterr   __static_attributes__r   r   r   r   r      s4    $7 7 ]]3 3r   r   c                 `   [        SS9n U R                  SS9nUR                  SSSS9  UR                  S	[        S
SS9nS Ul        UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  UR                  SSSS9  U R                  SSSS9  U R                  SSSS9  U $ )zCreate a jupyter parser object.zJupyter: Interactive Computing)descriptionF)requiredz	--version
store_truez3show the versions of core jupyter packages and exit)actionhelp
subcommand?zthe subcommand to launch)typenargsr1   c                     [        5       $ N)r   )argskwargss     r   <lambda> jupyter_parser.<locals>.<lambda>C   s    :J:Lr   z--config-dirzshow Jupyter config dirz
--data-dirzshow Jupyter data dirz--runtime-dirzshow Jupyter runtime dirz--pathsz?show all Jupyter paths. Add --json for machine-readable format.z--jsonz%output paths as machine-readable jsonz--debugz$output debug information about paths)r   add_mutually_exclusive_groupadd_argumentr!   	completer)parsergroupsubcommand_actions      r   jupyter_parserrB   5   s    4F ///?E	L/d   **3c0J +  #M	~lAZ[	|L?VW	|B\]	N  
 <cd
	,=cdMr   c            
       ^^ [        5       m[        5        H  n  [        [        U 5      R	                  5       5      nU H  nUR                  nUR                  S5      (       d  M'  [        R                  R                  S5      (       a  UR                  nTR                  [        UR                  S5      SS 5      5        M     M     [        5       nT HS  m[        UU4S j[        S[!        T5      5       5       5      (       a  M3  UR                  SR#                  T5      5        MU     [%        U5      $ ! [
         a     GM/  f = f)zList all jupyter subcommands

searches PATH for `jupyter-name`

Returns a list of jupyter's subcommand names, without the `jupyter-` prefix.
Nested children (e.g. jupyter-sub-subsub) are not included.
jupyter-win-r   Nc              3  4   >#    U  H  nTS U T;   v   M     g 7fr7   r   ).0isub_tupsubcommand_tupless     r   	<genexpr>#list_subcommands.<locals>.<genexpr>m   s     T=S72A;"33=Ss   )set_path_with_selflistr   iterdirOSErrorname
startswithsysplatformstemaddtuplesplitanyrangelenr   sorted)d	bin_pathspathrS   r   rJ   rK   s        @@r   r   r   S   s     	T!W__./I D99Dz**<<**51199D!%%eDJJsOAB,?&@A   %K$TU1c'l=STTTOOCHHW-. % +  		s   "D88
EEc                   [         R                  R                  S5      (       a  [        U 5      nUc   U < S3n[	        U[
        R                  5      e[        U/USS -   5      nSSKnUR                  UR                  UR                  5        UR                  5         [         R                  " UR                  5        g[        R                  " X5        g)zexecvp, except on Windows where it uses Popen

Python provides execvp on Windows, but its behavior is problematic (Python bug#9148).
rE   Nz
 not foundr   r   )rU   rV   rT   r   rR   errnoENOENTr   signalSIGINTSIG_IGNwaitexit
returncodeosexecvp)cmdargvcmd_pathmsgpre   s         r   _execvprr   r   s    
 ||u%% :G:&C#u||,,8*tABx'( 	fmmV^^4	
		#r   c                   [         R                  R                  [        5       5      nSU  3n[	        X!S9nUc  SU S3n[        U5      e[         R                  " U[         R                  5      (       d  SU S3n[        U5      eU$ )zVThis method get the abspath of a specified jupyter-subcommand with no
changes on ENV.
rD   )ra   z
Jupyter command `z` not found.z` is not executable.)rk   pathsepr   rO   r   	ExceptionaccessX_OK)r2   search_pathjupyter_subcommandabs_pathrp   s        r   _jupyter_abspathr{      s    
 **///"34K#J<0':H#$6#7|Dn99Xrww''#$6#77KLnOr   c                    [         R                  R                  S5      =(       d    [         R                  R	                  [         R
                  5      n  [        R                  " S5      nU R                  U5        [        R                  S   /n[        US   5      R                  5       (       a1  UR                  [         R                  R                  US   5      5        U H  n[!        [        U5      R"                  5      n[        U5      R%                  5       (       d  MA  [         R&                  " U[         R(                  5      (       d  Mm  U R+                  SU5        M     U $ ! [         a     Nf = f)zPut `jupyter`'s dir at the front of PATH

Ensures that /path/to/jupyter subcommand
will do /path/to/jupyter-subcommand
even if /other/jupyter-subcommand is ahead of it on PATH
PATHscriptsr   )rk   environgetdefpathrZ   rt   	sysconfigget_pathappendKeyErrorrU   rn   r   
is_symlinkra   realpathr!   parentis_dirrv   rw   insert)	path_listbindirr~   scripts       r   rO   rO      s    '52::<<RZZHI!##I.
 	 xx{mGGAJ""$$rww''
34T&\(()<  RYYvrww%?%? Q'  #  s   E) )
E65E6c                    SSK JnJn  U" 5       nU(       a1  [        U5      S:  a"  US   R	                  S5      (       d	  U" 5         U$ U R                  5         Sn[        U5      e! [         a    U R                  5          N)f = f)a	  If argcomplete is enabled, trigger autocomplete or return current words

If the first word looks like a subcommand, return the current command
that is attempting to be completed so that the subcommand can evaluate it;
otherwise auto-complete using the main parser.
r   )get_argcomplete_cwordsincrement_argcomplete_indexr   rF   z3Control flow should not reach end of autocomplete())#traitlets.config.argcomplete_configr   r   r]   rT   r   r   AssertionError)r?   r   r   cwordsrp   s        r   _evaluate_argcompleter      s    	

 ()c&kAofQi.B.B3.G.G ()M
 @C

   	s   AA& 	A& &BBc                    [        5       n [        R                  nSnS[        R                  ;   a  [        U 5      nUS   nGO [        U5      S:  a   US   R                  S5      (       d  US   nGOU R                  5       u  p4UR                  nUR                  (       aK  [        S5        S H9  n US:X  a  [        nO[        U5      nUR                  n [        US	 S
3U5        M;     gUR                  (       a'  UR                   (       d  [        R"                  " S5        UR$                  (       a'  UR                   (       d  [        R"                  " S5        UR$                  (       a'  UR                  (       a  [        R"                  " S5        UR&                  (       a  [        [         R(                  " 5       5        gUR*                  (       a  [        [         R,                  " 5       5        gUR.                  (       a  [        [         R0                  " 5       5        gUR                   (       Ga  0 n[         R0                  " 5       /US'   [         R2                  " 5       US'   [         R4                  " 5       US'   UR                  (       a   [        [        R6                  " U5      5        gUR$                  (       GaC  [        R                  n	[         R8                  " 5       (       a  [        S5        O[        S5        [         R:                  " 5       (       a  [        S5        O[        S5        U	R=                  S5      (       a  [        S5        O[        S5        U	R=                  S5      (       a  [        SU	R=                  S5       S35        O[        S5        U	R=                  S5      (       a  [        SU	R=                  S5       S35        O[        S5        [>        R@                  (       a#  [        S [>        RB                  " 5        S!35        O"[        S"[>        RB                  " 5        S!35        U	R=                  S#5      (       a  [        S$U	R=                  S#5       S%35        O[        S&5        U	R=                  S'5      (       a  [        S(U	R=                  S'5       S)35        O[        S*5        U	R=                  S+5      (       a  [        S,U	R=                  S+5       S-35        O[        S.5        [        5         [E        U5       H,  n
X   n[        U
 S
35        U H  n[        S/U-   5        M     M.     gU(       d3  U RG                  [        RH                  S09  [        R"                  " S15         [K        U5      n [Q        WU/US3S -   5        g! [         a    Sn GNf = f! [L         aQ  nU RG                  [        RH                  S09  US2:X  a   SnAg[        R"                  " [O        U5      5         SnAN~SnAff = f! [R         a'  n[        R"                  " S4U< S5U 35         SnAgSnAff = f)6zThe command entry point.N_ARGCOMPLETEr   rF   z!Selected Jupyter core packages...)IPython	ipykernel
ipywidgetsjupyter_clientjupyter_corejupyter_server
jupyterlabnbclient	nbconvertnbformatnotebook	qtconsole	traitletsr   znot installedz<17:z --json is only used with --pathsz!--debug is only used with --pathsz"--debug cannot be used with --jsonruntimeconfigdatazjJUPYTER_PLATFORM_DIRS is set to a true value, so we use platformdirs to find platform-specific directorieszJUPYTER_PLATFORM_DIRS is set to a false value, or is not set, so we use hardcoded legacy paths for platform-specific directorieszJUPYTER_PREFER_ENV_PATH is set to a true value, or JUPYTER_PREFER_ENV_PATH is not set and we detected a virtual environment, making the environment-level path preferred over the user-level path for data and configzJUPYTER_PREFER_ENV_PATH is set to a false value, or JUPYTER_PREFER_ENV_PATH is not set and we did not detect a virtual environment, making the user-level path preferred over the environment-level path for data and configJUPYTER_NO_CONFIGzWJUPYTER_NO_CONFIG is set, making the config path list only a single temporary directoryzEJUPYTER_NO_CONFIG is not set, so we use the full path list for configJUPYTER_CONFIG_PATHzJUPYTER_CONFIG_PATH is set to 'zO', which is prepended to the config path list (unless JUPYTER_NO_CONFIG is set)zQJUPYTER_CONFIG_PATH is not set, so we do not prepend anything to the config pathsJUPYTER_CONFIG_DIRzJUPYTER_CONFIG_DIR is set to 'z5', overriding the default user-level config directoryzPJUPYTER_CONFIG_DIR is not set, so we use the default user-level config directoryzKPython's site.ENABLE_USER_SITE is True, so we add the user site directory ''z]Python's site.ENABLE_USER_SITE is not True, so we do not add the Python site user directory 'JUPYTER_PATHzJUPYTER_PATH is set to 'z'', which is prepended to the data pathszHJUPYTER_PATH is not set, so we do not prepend anything to the data pathsJUPYTER_DATA_DIRzJUPYTER_DATA_DIR is set to 'z3', overriding the default user-level data directoryzLJUPYTER_DATA_DIR is not set, so we use the default user-level data directoryJUPYTER_RUNTIME_DIRzJUPYTER_RUNTIME_DIR is set to 'z+', overriding the default runtime directoryzGJUPYTER_RUNTIME_DIR is not set, so we use the default runtime directoryz    )filez>
Please specify a subcommand or one of the optional arguments.r1      z Error executing Jupyter command z: )*rB   rU   rn   rk   r   r   r]   rT   parse_known_argsr2   versionprintr
   
__import__r   jsonr	   ri   debug
config_dirjupyter_config_dirdata_dirjupyter_data_dirruntime_dirjupyter_runtime_dirjupyter_config_pathjupyter_pathdumpsuse_platform_dirsprefer_environment_over_userr   siteENABLE_USER_SITEgetuserbaser^   
print_helpstderrr{   ru   r!   rr   rR   )r?   rn   r2   r8   optspackager   modr   envrS   ra   rq   commandes                  r   mainr      sU   F88DJ#$V,!W
	TQtAw11#66 !W
,,.
__
<<56..0"-(1"%// Q'1/0 99TZZHH78::djjHH89::$))HH9:??%**,-==%((*+%++-.:::D$88:;DO"668DN --/DLyydjj&'@ } :::**C..00 I  _ 99;; t  {
 ww233u c ww455=cggF[>\=]  ^m  n o ww344<SWWEY=Z<[  \Q  R n ,,ijnjzjzj|i}}~ {  }A  }M  }M  }O  |P  PQ  R
 ww~..6sww~7N6OOvw f ww122:377CU;V:W  XK  L j
 ww455=cggF[>\=]  ^I  J e G"4LD:DTF!*%!fqj) " )
 szz*RS":.I'T!"X-.S # .-G.B  szz*Q  I3J>A3GHHIsN   2V?V>V1 
X V.-V.1
X;#X#XX
Y X;;Y __main__)r    r   )r    	list[str])rm   r!   rn   r   r    r"   )r2   r!   r    r!   )r?   r   r    r   r#   ) r(   
__future__r   argparserc   r   rk   r   rU   r   pathlibr   shutilr   
subprocessr   typingr    r	   r   r
   ArgumentParserr   rB   r   rr   r{   rO   r   r   r$   r   r   r   <module>r      s    #    	  
        H++ 4<>0(#L>qIh zF r   