3 \J@snddlZddlZddlZddlmZddlmZmZmZm Z m Z ddlm Z GdddZ Gddde Z dS) N)DistutilsOptionError)utildir_util file_util archive_utildep_util)logc@seZdZgZddZddZddZddZd d ZdBd dZ ddZ dCddZ ddZ dDddZ dEddZddZdFddZddZd d!Zd"d#Zd$d%ZdGd&d'ZdHd)d*Zd+d,Zd-d.Zd/d0ZdId1d2ZdJd4d5ZdKd6d7ZdLd8d9ZdMd:d;ZdNdd?Z dPd@dAZ!d S)QCommandcCsbddlm}t||std|jtkr0td||_|jd|_ |j |_ d|_ d|_ d|_ dS)Nr) Distributionz$dist must be a Distribution instancezCommand is an abstract class)Zdistutils.distr isinstance TypeError __class__r RuntimeError distributioninitialize_optionsZ_dry_runverboseforcehelp finalized)selfZdistr r%/usr/lib64/python3.6/distutils/cmd.py__init__/s    zCommand.__init__cCs<|dkr0t|d|}|dkr*t|j|S|Snt|dS)Ndry_run_)getattrrAttributeError)rattrZmyvalrrr __getattr___s  zCommand.__getattr__cCs|js|jd|_dS)N)rfinalize_options)rrrrensure_finalizediszCommand.ensure_finalizedcCstd|jdS)Nz,abstract method -- subclass %s must override)rr )rrrrr{s zCommand.initialize_optionscCstd|jdS)Nz,abstract method -- subclass %s must override)rr )rrrrr s zCommand.finalize_optionsNcCsddlm}|dkr d|j}|j||tjd|d}x\|jD]R\}}}|j|}|d dkrp|dd }t||}|j|d||ftjdqDWdS) Nr) longopt_xlatezcommand options for '%s':)levelz r=z%s = %sr&) Zdistutils.fancy_getoptr#get_command_nameannouncerINFO user_options translater)rheaderindentr#optionrvaluerrr dump_optionss      zCommand.dump_optionscCstd|jdS)Nz,abstract method -- subclass %s must override)rr )rrrrruns z Command.runrcCstj||dS)N)r)rmsgr$rrrr(szCommand.announcecCs&ddlm}|r"t|tjjdS)Nr)DEBUG)Zdistutils.debugr3printsysstdoutflush)rr2r3rrr debug_prints zCommand.debug_printcCsBt||}|dkr"t||||St|ts>td|||f|S)Nz'%s' must be a %s (got `%s`))rsetattrr strr)rr.whatdefaultvalrrr_ensure_stringlikes   zCommand._ensure_stringlikecCs|j|d|dS)Nstring)r>)rr.r<rrr ensure_stringszCommand.ensure_stringcCspt||}|dkrdSt|tr6t||tjd|n6t|trTtdd|D}nd}|sltd||fdS)Nz,\s*|\s+css|]}t|tVqdS)N)r r:).0vrrr sz-Command.ensure_string_list..Fz''%s' must be a list of strings (got %r)) rr r:r9resplitlistallr)rr.r=okrrrensure_string_lists   zCommand.ensure_string_listcCs8|j|||}|dk r4|| r4td|||fdS)Nzerror in '%s' option: )r>r)rr.Ztesterr;Z error_fmtr<r=rrr_ensure_tested_stringszCommand._ensure_tested_stringcCs|j|tjjdddS)Nfilenamez$'%s' does not exist or is not a file)rJospathisfile)rr.rrrensure_filenames zCommand.ensure_filenamecCs|j|tjjdddS)Nzdirectory namez)'%s' does not exist or is not a directory)rJrLrMisdir)rr.rrrensure_dirnames zCommand.ensure_dirnamecCst|dr|jS|jjSdS)N command_name)hasattrrRr __name__)rrrrr' s zCommand.get_command_namecGsJ|jj|}|jx0|D](\}}t||dkrt||t||qWdS)N)rget_command_objr!rr9)rZsrc_cmdZ option_pairsZ src_cmd_objZ src_optionZ dst_optionrrrset_undefined_optionss  zCommand.set_undefined_optionscCs|jj||}|j|S)N)rrUr!)rcommandZcreateZcmd_objrrrget_finalized_command$szCommand.get_finalized_commandrcCs|jj||S)N)rreinitialize_command)rrWZreinit_subcommandsrrrrY0szCommand.reinitialize_commandcCs|jj|dS)N)r run_command)rrWrrrrZ4szCommand.run_commandcCs6g}x,|jD]"\}}|dks$||r |j|q W|S)N) sub_commandsappend)rZcommandsZcmd_namemethodrrrget_sub_commands;s zCommand.get_sub_commandscCstjd|j|dS)Nzwarning: %s: %s )rwarnr')rr2rrrr_Ksz Command.warncCstj||||jddS)N)r)rexecuter)rfuncargsr2r$rrrr`NszCommand.executecCstj|||jddS)N)r)rmkpathr)rnamemoderrrrdQszCommand.mkpathc Cstj|||||j ||jdS)N)r)r copy_filerr)rinfileoutfile preserve_modepreserve_timeslinkr$rrrrgTs  zCommand.copy_filec Cstj||||||j |jdS)N)r)r copy_treerr)rrhrirjrkZpreserve_symlinksr$rrrrm]s zCommand.copy_treecCstj|||jdS)N)r)r move_filer)rsrcdstr$rrrrnfszCommand.move_filecCs ddlm}||||jddS)Nr)spawn)r)Zdistutils.spawnrqr)rcmdZ search_pathr$rqrrrrqjs z Command.spawnc Cstj|||||j||dS)N)rownergroup)r make_archiver)rZ base_nameformatZroot_dirZbase_dirrsrtrrrruos zCommand.make_archivecCs|dkrd|}t|tr"|f}nt|ttfs8td|dkrRd|dj|f}|jsdtj||rv|j ||||n t j |dS)Nzskipping %s (inputs unchanged)z9'infiles' must be a string, or a list or tuple of stringszgenerating %s from %sz, ) r r:rFtupler joinrrZ newer_groupr`rdebug)rZinfilesrirarbZexec_msgZskip_msgr$rrr make_fileus  zCommand.make_file)Nr")r)N)N)N)r)r)Nr)rc)rrNr)rrrr)r)rr)NNNN)NNr)"rT __module__ __qualname__r[rrr!rr r0r1r(r8r>r@rIrJrOrQr'rVrXrYrZr^r_r`rdrgrmrnrqrurzrrrrr sD0              r c@s2eZdZd gZddZddZdd Zd d Zd S) install_misc install-dir=d!directory to install the files tocCsd|_g|_dS)N) install_diroutfiles)rrrrrszinstall_misc.initialize_optionscCs|jd|dfdS)NZinstallr)rV)rdirnamerrr_install_dir_fromszinstall_misc._install_dir_fromcCsRg|_|sdS|j|jx2|D]*}|j||j|jjtjj|j|q WdS)N)rrdrrgr\rLrMrx)rZfilelistfrrr _copy_filess  zinstall_misc._copy_filescCs|jS)N)r)rrrr get_outputsszinstall_misc.get_outputsN)r~rr)rTr{r|r*rrrrrrrrr}s  r})r5rLrDZdistutils.errorsrZ distutilsrrrrrrr r}rrrrs