
    5i6                        d Z ddlZddlZddlZddlZddlZddlZddlZdZdZ	dZ
 ej                  e ej                        Zej                  ddd	d
       ej                  dd       ej                  ddd
        ej                  e       dad Zd Zd Zd Zd Zd Zd Zd ZddZd Zd Zd Zd Zedk(  r ej>                   e              yy) zm
Activate the generic bash-completion script or zsh completion autoload function for the argcomplete module.
    Nzargcomplete.scriptsz_
# Begin added by argcomplete
fpath=( {zsh_fpath} "${{fpath[@]}}" )
# End added by argcomplete
zN
# Begin added by argcomplete
source "{activator}"
# End added by argcomplete
)descriptionformatter_classz-yz--yesz*automatically answer yes for all questions
store_true)helpactionz--destzQSpecify the shell completion modules directory to install into, or "-" for stdout)r   z--userzInstall into user directoryc                      	 t        j                  ddg      j                         j                         S # t        t         j
                  f$ r Y yw xY w)Nbrewz--prefixz
/usr/local)
subprocesscheck_outputdecodestripFileNotFoundErrorCalledProcessError     /home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/argcomplete/scripts/activate_global_python_argcomplete.pyget_local_dirr   +   sL    &&
';<CCEKKMMz<<= s   25 AAc                      t                dS )Nz/share/zsh/site-functions)r   r   r   r   get_zsh_system_dirr   2   s    o788r   c                      dt         j                  v rt         j                  d   S t        j                  dk(  rt	                dS y)NBASH_COMPLETION_COMPAT_DIRdarwinz/etc/bash_completion.d)osenvironsysplatformr   r   r   r   get_bash_system_dirr   6   s>    #rzz1zz677		!/""899'r   c                      t         j                  j                  t         j                  j                  t         j                  j	                  t
        j                              d      S )Nzbash_completion.d)r   pathjoinabspathdirnameargcomplete__file__r   r   r   get_activator_dirr%   ?   s8    77<<8L8L(MNPcddr   c                  R    t         j                  j                  t               d      S )Nz_python-argcomplete)r   r   r    r%   r   r   r   get_activator_pathr'   C   s    77<<)+-BCCr   c                    t               }| dk(  rBt        |      5 }t        j                  j	                  |j                                d d d        y t        j                  j                  |       }t        j                  j                  |      s	 t        j                  |d       	 t        d| d|  d	t        j                  
       t!        j"                  ||        t        dt        j                  
       y # 1 sw Y   y xY w# t        $ r&}t        j                  d| d| d       Y d }~d }~ww xY w# t        $ r&}t        j                  d|  d| d       Y d }~y d }~ww xY w)N-T)exist_okzpath z* does not exist and could not be created: zE. Please run this command using sudo, or see --help for more options.zInstalling z to ...filez
Installed.zwhile installing to z: )r'   openr   stdoutwritereadr   r   r"   existsmakedirs	Exceptionparsererrorprintstderrshutilcopy)dest	activatorfhdestdires        r   install_to_destinationr@   G   s-   "$Is{)_ 	(JJRWWY'	(ggood#G77>>'"	KK$/

I;d4&43::FIt$l,	(
  	LLy J1#  NS  T 	  
"4&1#-rs	
 	

s<   .C=D	 )AD; =D		D8D33D8;	E*E%%E*c                      t         J t         j                  du ry	 t        d      } | j                         dvrt	        dt
        j                         n| j                         dv ryyN)NTzOK to proceed? [y/n] >   nynoyeszPlease answer "yes" or "no".r,   >   rC   rE   F)argsrE   inputlowerr7   r   r8   )ress    r   get_consentrJ   _   sb    xx4
+,99;550szzBYY[L( r   c                    t         j                  j                  |       rt        | d      5 }||j	                         v r)t        d|  dt        j                         	 d d d        y 	 d d d        t        d|  dt        j                         |j                         D ]  }t        d|t        j                           t               st        dt        j                         y t        d	|  d
t        j                         t        | d      5 }|j                  |       d d d        t        dt        j                         y # 1 sw Y   xY w# 1 sw Y   1xY w)Nrz$The code already exists in the file .r,   z(argcomplete needs to append to the file z&. The following code will be appended:>z
Not added.zAdding shellcode to r+   azAdded.)r   r   r2   r.   r1   r7   r   r8   
splitlinesrJ   r0   )r   	shellcoder=   lines       r   append_to_config_filerS   m   s   	ww~~d$_ 	BGGI%<TF!D3::V	 	%	 	8>delolvlvw((* 	.D#t#**-	.},SZZ0	 c
*<	dC B
	($	 	 s   3EEEEc                    t         j                  j                  t         j                  j                  t         j                  j                  dd            d      }t        |t        j                  | xs
 t                            y )NZDOTDIR~z.zshenv	zsh_fpath)
r   r   r    
expanduserr   getrS   zsh_shellcodeformatr%   )rX   
zsh_rcfiles     r   link_zsh_user_rcfiler^      sV    bgg00	31OPR[\J*m&:&:YEeRcRe&:&fgr   c                      t         j                  j                  d      } t        | t        j                  t                            y )Nz~/.bash_completion)r<   )r   r   rY   rS   bash_shellcoder\   r'   )bash_completion_user_files    r   link_bash_user_rcfilerb      s5     " 2 23G H3^5J5JUgUi5J5jkr   c                  ,    t                t                y N)r^   rb   r   r   r   link_user_rcfilesre      s    r   c                  \   dt         j                  j                  dd      vry 	 t               } t	        j
                  t         j                  d   ddg      }|j                         j                         D ]	  }|| k(  s	 y  t        |        y # t        t        j                  f$ r Y y w xY w)NzshSHELL z-czprintf "%s
" "${fpath[@]}"rW   )r   r   rZ   r   r
   r   r   rP   r^   r   r   )zsh_system_dirfpath_outputfpaths      r   $add_zsh_system_dir_to_fpath_for_userrm      s    BJJNN7B//+-!..

70CTKh/ij!((*557 	E&	 	~6z<<= s   AB ?B B B+*B+c                  &   t         j                         ag } t        j                  rt        j                  dk7  rTt        j
                  j                  t        j                        s't         j                  dt        j                   d       | j                  t        j                         nt        j                  rVt        j                  rFt        j                  t        j                  v r&t        dt        j                          t#                nt        j$                  t        j&                  k7  r&t        dt        j                          t#                nnt        j(                  rt#                nSt        dt        j                          | j                  t+                d       | j                  t-                d	       | D ]  }t/        |        t1                t        j                  t        d
t        j                          y y )Nr)   z
directory z0 was specified via --dest, but it does not existz\Argcomplete was installed in the user site local directory. Defaulting to user installation.r,   zTArgcomplete was installed in a virtual environment. Defaulting to user installation.z'Defaulting to system-wide installation.z/_python-argcompletez/python-argcompletezFPlease restart your shell or source the installed file to activate it.)r5   
parse_argsrF   r;   r   r   r2   r6   appendsiteENABLE_USER_SITE	USER_SITEr#   r$   r7   r   r8   re   prefixbase_prefixuserr   r   r@   rm   )destinationsdestinations     r   mainry      s[   DLyy99BGGNN499$=LL:dii[0`abDII&			4>>dnnH\H\6\j	
 		s	&dknkukuv	7cjjI1344HIJ2455HIJ# ,{+, )*yyV]`]g]gh r   __main__rd   ) __doc__argparser   r9   rq   r
   r   r#   __package__r[   r`   ArgumentParserRawDescriptionHelpFormatterr5   add_argumentautocompleterF   r   r   r   r%   r'   r@   rJ   rS   r^   rb   re   rm   ry   __name__exitr   r   r   <module>r      s    	    
  $ 
!	 	 WhFjFj	k   D'(T]i  j   H#v  w   H#@  V     9(eD
0%$h
l
 iF zCHHTV r   