a �DOg�F�@s^ddlZddlZddlZddlmZddlmZmZmZm Z m Z ddlm Z Gdd�d�Z dS)�N)�DistutilsOptionError)�util�dir_util� file_util� archive_util�dep_util��logc@seZdZgZdd�Zdd�Zdd�Zdd�Zd d �ZdBd d�Z dd�Z dCdd�Z dd�Z dDdd�Z dEdd�Zdd�ZdFdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdGd&d'�ZdHd)d*�Zd+d,�Zd-d.�Zd/d0�ZdId1d2�ZdJd4d5�ZdKd6d7�ZdLd8d9�ZdMd:d;�ZdNdd?�Z dPd@dA�Z!d S)Q�CommandcCsbddlm}t||�std��|jtur0td��||_|��d|_ |j |_ d|_ d|_ d|_ dS)Nr)� Distributionz$dist must be a Distribution instancezCommand is an abstract class)Zdistutils.distr � isinstance� TypeError� __class__r � RuntimeError� distribution�initialize_optionsZ_dry_run�verbose�force�help� finalized)�self�distr �r�%/usr/lib64/python3.9/distutils/cmd.py�__init__/s    zCommand.__init__cCs<|dkr0t|d|�}|dur*t|j|�S|Snt|��dS)N�dry_run�_)�getattrr�AttributeError)r�attrZmyvalrrr� __getattr___s  zCommand.__getattr__cCs|js|��d|_dS)N�)r�finalize_options�rrrr�ensure_finalizediszCommand.ensure_finalizedcCstd|j��dS�Nz,abstract method -- subclass %s must override�rrr#rrrr{s �zCommand.initialize_optionscCstd|j��dSr%r&r#rrrr"�s �zCommand.finalize_optionsN�cCs�ddlm}|dur d|��}|j||tjd�|d}|jD]R\}}}|�|�}|ddkrn|dd�}t||�}|j|d||ftjd�qBdS) Nr)� longopt_xlatezcommand options for '%s':)�levelz ������=z%s = %s) Zdistutils.fancy_getoptr(�get_command_name�announcer �INFOZ user_options� translater)r�header�indentr(�optionr�valuerrr� dump_options�s      �zCommand.dump_optionscCstd|j��dSr%r&r#rrr�run�s �z Command.runr!cCst�||�dS�Nr)r�msgr)rrrr-�szCommand.announcecCs&ddlm}|r"t|�tj��dS)Nr)�DEBUG)Zdistutils.debugr8�print�sys�stdout�flush)rr7r8rrr� debug_print�s zCommand.debug_printcCsBt||�}|dur"t|||�|St|t�s>td|||f��|S)Nz'%s' must be a %s (got `%s`))r�setattrr �strr)rr2�what�default�valrrr�_ensure_stringlike�s   �zCommand._ensure_stringlikecCs|�|d|�dS)N�string)rC)rr2rArrr� ensure_string�szCommand.ensure_stringcCspt||�}|durdSt|t�r6t||t�d|��n6t|t�rTtdd�|D��}nd}|sltd||f��dS)Nz,\s*|\s+css|]}t|t�VqdSr6)r r?)�.0�vrrr� ��z-Command.ensure_string_list..Fz''%s' must be a list of strings (got %r)) rr r?r>�re�split�list�allr)rr2rB�okrrr�ensure_string_list�s   ��zCommand.ensure_string_listcCs6|�|||�}|dur2||�s2td|||f��dS)Nzerror in '%s' option: )rCr)rr2Ztesterr@Z error_fmtrArBrrr�_ensure_tested_string�s �zCommand._ensure_tested_stringcCs|�|tjjdd�dS)N�filenamez$'%s' does not exist or is not a file)rP�os�path�isfile�rr2rrr�ensure_filename�s �zCommand.ensure_filenamecCs|�|tjjdd�dS)Nzdirectory namez)'%s' does not exist or is not a directory)rPrRrS�isdirrUrrr�ensure_dirnames �zCommand.ensure_dirnamecCst|d�r|jS|jjSdS)N� command_name)�hasattrrYr�__name__r#rrrr, s zCommand.get_command_namecGsF|j�|�}|��|D](\}}t||�durt||t||��qdSr6)r�get_command_objr$rr>)rZsrc_cmdZ option_pairsZ src_cmd_objZ src_optionZ dst_optionrrr�set_undefined_optionss   zCommand.set_undefined_optionscCs|j�||�}|��|Sr6)rr\r$)r�commandZcreateZcmd_objrrr�get_finalized_command$szCommand.get_finalized_commandrcCs|j�||�Sr6)r�reinitialize_command)rr^Zreinit_subcommandsrrrr`0s�zCommand.reinitialize_commandcCs|j�|�dSr6)r� run_command)rr^rrrra4szCommand.run_commandcCs2g}|jD]"\}}|dus"||�r |�|�q |Sr6)� sub_commands�append)r�commandsZcmd_name�methodrrr�get_sub_commands;s  zCommand.get_sub_commandscCst�d|��|�dS)Nzwarning: %s: %s )r �warnr,)rr7rrrrgKsz Command.warncCstj||||jd�dS�N�r)r�executer)r�func�argsr7r)rrrrjNszCommand.execute��cCstj|||jd�dSrh)r�mkpathr)r�name�moderrrrnQszCommand.mkpathc Cstj|||||j ||jd�Srh)r� copy_filerr)r�infile�outfile� preserve_mode�preserve_times�linkr)rrrrqTs  �zCommand.copy_filec Cstj||||||j |jd�Srh)r� copy_treerr)rrrrsrtruZpreserve_symlinksr)rrrrw]s  �zCommand.copy_treecCstj|||jd�Srh)r� move_filer)r�src�dstr)rrrrxfszCommand.move_filecCs ddlm}||||jd�dS)Nr)�spawnri)Zdistutils.spawnr{r)r�cmd� search_pathr)r{rrrr{js z Command.spawnc Cstj|||||j||d�S)N)r�owner�group)r� make_archiver)r� base_name�format�root_dir�base_dirr~rrrrr�os �zCommand.make_archivecCs�|durd|}t|t�r"|f}nt|ttf�s8td��|durRd|d�|�f}|jsdt�||�rv|� ||||�n t � |�dS)Nzskipping %s (inputs unchanged)z9'infiles' must be a string, or a list or tuple of stringszgenerating %s from %sz, ) r r?rL�tupler �joinrrZ newer_grouprjr �debug)rZinfilesrsrkrlZexec_msgZskip_msgr)rrr� make_fileus  �zCommand.make_file)Nr')r!)N)N)N)r!)r)Nr!)rm)r!r!Nr!)r!r!rr!)r!)r!r!)NNNN)NNr!)"r[� __module__� __qualname__rbrr r$rr"r4r5r-r=rCrErOrPrVrXr,r]r_r`rarfrgrjrnrqrwrxr{r�r�rrrrr sN0     �    � �  � �r ) r:rRrJZdistutils.errorsrZ distutilsrrrrrr r rrrr�s