o
    ?@i                     @   s  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dZejddd	d
d ejddd ejddd
d ee dadd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zed%kree  dS dS )&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                	   C   s4   zt ddg  W S  tt jfy   Y dS w )Nbrewz--prefixz
/usr/local)
subprocesscheck_outputdecodestripFileNotFoundErrorCalledProcessError r   r   t/home/ubuntu/transcripts/venv/lib/python3.10/site-packages/argcomplete/scripts/activate_global_python_argcomplete.pyget_local_dir+   s
   r   c                   C   s   t   dS )Nz/share/zsh/site-functions)r   r   r   r   r   get_zsh_system_dir2   s   r   c                   C   s.   dt jv r
t jd S tjdkrt  dS dS )NBASH_COMPLETION_COMPAT_DIRdarwinz/etc/bash_completion.d)osenvironsysplatformr   r   r   r   r   get_bash_system_dir6   s
   


r   c                   C   s    t jt jt jtjdS )Nzbash_completion.d)r   pathjoinabspathdirnameargcomplete__file__r   r   r   r   get_activator_dir?   s    r   c                   C   s   t jt dS )Nz_python-argcomplete)r   r   r   r   r   r   r   r   get_activator_pathC   s   r    c              
   C   s.  t  }| dkr&t|}tj|  W d    d S 1 sw   Y  d S tj| }tj	|sYz	tj
|dd W n tyX } ztd| d|  W Y d }~nd }~ww ztd| d|  dtjd	 t||  td
tjd	 W d S  ty } ztd|  d| d W Y d }~d S d }~ww )N-T)exist_okzpath z* does not exist and could not be created: zInstalling z to ...filez
Installed.zwhile installing to z: zE. Please run this command using sudo, or see --help for more options.)r    openr   stdoutwritereadr   r   r   existsmakedirs	Exceptionparsererrorprintstderrshutilcopy)dest	activatorfhdestdirer   r   r   install_to_destinationG   s4   

"r8   c                  C   sV   t d usJ t jdu rdS 	 td} |  dvr tdtjd n
|  dv r(dS dS q)NTzOK to proceed? [y/n] >   nynoyeszPlease answer "yes" or "no".r$   >   r:   r<   F)argsr<   inputlowerr/   r   r0   )resr   r   r   get_consent]   s   
rA   c                 C   s  t j| r[t| d"}|| v r&td|  dtjd 	 W d    d S W d    n1 s0w   Y  td|  dtjd | D ]
}td|tjd qDt	 s[tdtjd d S td	|  d
tjd t| d}|
| W d    n1 s{w   Y  tdtjd d S )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   r*   r&   r)   r/   r   r0   
splitlinesrA   r(   )r   	shellcoder5   liner   r   r   append_to_config_filek   s&   rI   c                  C   sX   t jt jt jddd} t| tjt	 d t jd}t|t
jt d d S )NZDOTDIR~z.zshenv)	zsh_fpathz~/.bash_completion)r4   )r   r   r   
expanduserr   getrI   zsh_shellcodeformatr   bash_shellcoder    )
zsh_rcfilebash_completion_user_filer   r   r   link_user_rcfiles}   s    rT   c                  C   s  t  ag } tjr&tjdkrtjtjst dtj d | tj nHt	j
r=t	jr=t	jtjv r=tdtjd t  n1tjtjkrNtdtjd t  n tjrUt  ntdtjd | t  d | t  d	 | D ]}t| qptjd u rtd
tjd d S d S )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.)r-   
parse_argsr=   r3   r   r   r*   r.   appendsiteENABLE_USER_SITE	USER_SITEr   r   r/   r   r0   rT   prefixbase_prefixuserr   r   r8   )destinationsdestinationr   r   r   main   s2   

r_   __main__)__doc__argparser   r1   rW   r   r   r   __package__rO   rQ   ArgumentParserRawDescriptionHelpFormatterr-   add_argumentautocompleter=   r   r   r   r   r    r8   rA   rI   rT   r_   __name__exitr   r   r   r   <module>   s<   
		!