a DOgF@s^ddlZddlZddlZddlmZddlmZmZmZm Z m Z ddlm Z GdddZ dS)N)DistutilsOptionError)utildir_util file_util archive_utildep_utillogc@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|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 distributioninitialize_optionsZ_dry_runverboseforcehelp finalized)selfdistr r%/usr/lib64/python3.9/distutils/cmd.py__init__/s    zCommand.__init__cCs<|dkr0t|d|}|dur*t|j|S|Snt|dS)Ndry_run_)getattrrAttributeError)rattrZmyvalrrr __getattr___s  zCommand.__getattr__cCs|js|d|_dS)N)rfinalize_optionsrrrrensure_finalizediszCommand.ensure_finalizedcCstd|jdSNz,abstract method -- subclass %s must overriderrr#rrrr{s zCommand.initialize_optionscCstd|jdSr%r&r#rrrr"s zCommand.finalize_optionsNcCsddlm}|dur d|}|j||tjd|d}|jD]R\}}}||}|ddkrn|dd}t||}|j|d||ftjdqBdS) Nr) longopt_xlatezcommand options for '%s':)levelz =z%s = %s) Zdistutils.fancy_getoptr(get_command_nameannouncer INFOZ user_options translater)rheaderindentr(optionrvaluerrr dump_optionss      zCommand.dump_optionscCstd|jdSr%r&r#rrrruns z Command.runr!cCst||dSNr)rmsgr)rrrr-szCommand.announcecCs&ddlm}|r"t|tjdS)Nr)DEBUG)Zdistutils.debugr8printsysstdoutflush)rr7r8rrr debug_prints zCommand.debug_printcCsBt||}|dur"t||||St|ts>td|||f|S)Nz'%s' must be a %s (got `%s`))rsetattrr strr)rr2whatdefaultvalrrr_ensure_stringlikes   zCommand._ensure_stringlikecCs||d|dS)Nstring)rC)rr2rArrr ensure_stringszCommand.ensure_stringcCspt||}|durdSt|tr6t||td|n6t|trTtdd|D}nd}|sltd||fdS)Nz,\s*|\s+css|]}t|tVqdSr6)r r?).0vrrr z-Command.ensure_string_list..Fz''%s' must be a list of strings (got %r)) rr r?r>resplitlistallr)rr2rBokrrrensure_string_lists   zCommand.ensure_string_listcCs6||||}|dur2||s2td|||fdS)Nzerror in '%s' option: )rCr)rr2Ztesterr@Z error_fmtrArBrrr_ensure_tested_strings zCommand._ensure_tested_stringcCs||tjjdddS)Nfilenamez$'%s' does not exist or is not a file)rPospathisfilerr2rrrensure_filenames zCommand.ensure_filenamecCs||tjjdddS)Nzdirectory namez)'%s' does not exist or is not a directory)rPrRrSisdirrUrrrensure_dirnames zCommand.ensure_dirnamecCst|dr|jS|jjSdS)N command_name)hasattrrYr__name__r#rrrr, s zCommand.get_command_namecGsF|j|}||D](\}}t||durt||t||qdSr6)rget_command_objr$rr>)rZsrc_cmdZ option_pairsZ src_cmd_objZ src_optionZ dst_optionrrrset_undefined_optionss   zCommand.set_undefined_optionscCs|j||}||Sr6)rr\r$)rcommandZcreateZcmd_objrrrget_finalized_command$szCommand.get_finalized_commandrcCs|j||Sr6)rreinitialize_command)rr^Zreinit_subcommandsrrrr`0szCommand.reinitialize_commandcCs|j|dSr6)r run_command)rr^rrrra4szCommand.run_commandcCs2g}|jD]"\}}|dus"||r ||q |Sr6) sub_commandsappend)rcommandsZcmd_namemethodrrrget_sub_commands;s  zCommand.get_sub_commandscCstd||dS)Nzwarning: %s: %s )r warnr,)rr7rrrrgKsz Command.warncCstj||||jddSNr)rexecuter)rfuncargsr7r)rrrrjNszCommand.executecCstj|||jddSrh)rmkpathr)rnamemoderrrrnQszCommand.mkpathc Cstj|||||j ||jdSrh)r copy_filerr)rinfileoutfile preserve_modepreserve_timeslinkr)rrrrqTs  zCommand.copy_filec Cstj||||||j |jdSrh)r copy_treerr)rrrrsrtruZpreserve_symlinksr)rrrrw]s  zCommand.copy_treecCstj|||jdSrh)r move_filer)rsrcdstr)rrrrxfszCommand.move_filecCs ddlm}||||jddS)Nr)spawnri)Zdistutils.spawnr{r)rcmd search_pathr)r{rrrr{js z Command.spawnc Cstj|||||j||dS)N)rownergroup)r make_archiver)r base_nameformatroot_dirbase_dirr~rrrrros zCommand.make_archivecCs|durd|}t|tr"|f}nt|ttfs8td|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?rLtupler 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{rrrrrrr sN0             r ) r:rRrJZdistutils.errorsrZ distutilsrrrrrr r rrrrs