B YI~d�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;�ZdNd<d=�ZdOd>d?�Z dPd@dA�Z!d S)Q�CommandcCsbddlm}t||�std��|jtkr0td��||_|��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)�selfZdistr �r�2/opt/alt/python37/lib64/python3.7/distutils/cmd.py�__init__/s    zCommand.__init__cCs<|dkr0t|d|�}|dkr*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)rr )rrrrr{s zCommand.initialize_optionscCstd|j��dS)Nz,abstract method -- subclass %s must override)rr )rrrrr �s zCommand.finalize_optionsN�cCs�ddlm}|dkr d|��}|j||tjd�|d}x\|jD]R\}}}|�|�}|ddkrp|dd�}t||�}|j|d||ftjd�qDWdS) 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��dS)Nz,abstract method -- subclass %s must override)rr )rrrr�run�s z Command.runrcCst�||�dS)N)r)r�msgr$rrrr(�szCommand.announcecCs&ddlm}|r"t|�tj��dS)Nr)�DEBUG)Zdistutils.debugr2�print�sys�stdout�flush)rr1r2rrr� debug_print�s zCommand.debug_printcCsBt||�}|dkr"t|||�|St|t�s>td|||f��|S)Nz'%s' must be a %s (got `%s`))r�setattrr �strr)rr-�what�default�valrrr�_ensure_stringlike�s   zCommand._ensure_stringlikecCs|�|d|�dS)N�string)r=)rr-r;rrr� ensure_string�szCommand.ensure_stringcCspt||�}|dkrdSt|t�r6t||t�d|��n6t|t�rTtdd�|D��}nd}|sltd||f��dS)Nz,\s*|\s+css|]}t|t�VqdS)N)r r9)�.0�vrrr� <genexpr>�sz-Command.ensure_string_list.<locals>.<genexpr>Fz''%s' must be a list of strings (got %r)) rr r9r8�re�split�list�allr)rr-r<�okrrr�ensure_string_list�s   zCommand.ensure_string_listcCs6|�|||�}|dk r2||�s2td|||f��dS)Nzerror in '%s' option: )r=r)rr-Ztesterr:Z error_fmtr;r<rrr�_ensure_tested_string�szCommand._ensure_tested_stringcCs|�|tjjdd�dS)N�filenamez$'%s' does not exist or is not a file)rI�os�path�isfile)rr-rrr�ensure_filename�s zCommand.ensure_filenamecCs|�|tjjdd�dS)Nzdirectory namez)'%s' does not exist or is not a directory)rIrKrL�isdir)rr-rrr�ensure_dirnames zCommand.ensure_dirnamecCst|d�r|jS|jjSdS)N� command_name)�hasattrrQr �__name__)rrrrr' s zCommand.get_command_namecGsJ|j�|�}|��x0|D](\}}t||�dkrt||t||��qWdS)N)r�get_command_objr!rr8)rZsrc_cmdZ option_pairsZ src_cmd_objZ src_optionZ dst_optionrrr�set_undefined_optionss  zCommand.set_undefined_optionscCs|j�||�}|��|S)N)rrTr!)r�commandZcreateZcmd_objrrr�get_finalized_command$szCommand.get_finalized_commandrcCs|j�||�S)N)r�reinitialize_command)rrVZreinit_subcommandsrrrrX0szCommand.reinitialize_commandcCs|j�|�dS)N)r� run_command)rrVrrrrY4szCommand.run_commandcCs6g}x,|jD]"\}}|dks$||�r |�|�q W|S)N)� sub_commands�append)rZcommandsZcmd_name�methodrrr�get_sub_commands;s zCommand.get_sub_commandscCst�d|��|�dS)Nzwarning: %s: %s )r�warnr')rr1rrrr^Ksz Command.warncCstj||||jd�dS)N)r)r�executer)r�func�argsr1r$rrrr_NszCommand.execute�cCstj|||jd�dS)N)r)r�mkpathr)r�name�moderrrrcQszCommand.mkpathc Cstj|||||j ||jd�S)N)r)r� copy_filerr)r�infile�outfile� preserve_mode�preserve_times�linkr$rrrrfTs  zCommand.copy_filec Cstj||||||j |jd�S)N)r)r� copy_treerr)rrgrhrirjZpreserve_symlinksr$rrrrl]s zCommand.copy_treecCstj|||jd�S)N)r)r� move_filer)r�src�dstr$rrrrmfszCommand.move_filecCs ddlm}||||jd�dS)Nr)�spawn)r)Zdistutils.spawnrpr)r�cmdZ search_pathr$rprrrrpjs z Command.spawnc Cstj|||||j||d�S)N)r�owner�group)r� make_archiver)rZ base_name�formatZroot_dirZbase_dirrrrsrrrrtos zCommand.make_archivecCs�|dkrd|}t|t�r"|f}nt|ttf�s8td��|dkrRd|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 r9rE�tupler �joinrrZ newer_groupr_r�debug)rZinfilesrhr`raZexec_msgZskip_msgr$rrr� make_fileus  zCommand.make_file)Nr")r)N)N)N)r)r)Nr)rb)rrNr)rrrr)r)rr)NNNN)NNr)"rS� __module__� __qualname__rZrrr!rr r/r0r(r7r=r?rHrIrNrPr'rUrWrXrYr]r^r_rcrfrlrmrprtryrrrrr sD0              r ) r4rKrCZdistutils.errorsrZ distutilsrrrrrrr rrrr�<module>s