efExdZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z ddl mZGddZdS) ztdistutils.cmd Provides the Command class, the base class for the command classes in the distutils.command package. N)DistutilsOptionError)utildir_util file_util archive_util _modifiedlogceZdZdZgZdZdZdZdZdZ d%d Z d Z e j fd Zd Zd&d Zd&dZdZd&dZdZdZdZdZd'dZd(dZdZdZdZd)dZd*dZ d+dZ d,d Z d'd!Z!d-d"Z" d.d#Z# d/d$Z$dS)0Commanda}Abstract base class for defining command classes, the "worker bees" of the Distutils. A useful analogy for command classes is to think of them as subroutines with local variables called "options". The options are "declared" in 'initialize_options()' and "defined" (given their final values, aka "finalized") in 'finalize_options()', both of which must be defined by every command class. The distinction between the two is necessary because option values might come from the outside world (command line, config file, ...), and any options dependent on other options must be computed *after* these outside influences have been processed -- hence 'finalize_options()'. The "body" of the subroutine, where it does all its work based on the values of its options, is the 'run()' method, which must also be implemented by every command class. cddlm}t||std|jt urt d||_|d|_ |j |_ d|_ d|_ d|_ dS)zCreate and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated. r) Distributionz$dist must be a Distribution instancezCommand is an abstract classN)distutils.distr isinstance TypeError __class__r RuntimeError distributioninitialize_options_dry_runverboseforcehelp finalized)selfdistrs y/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/_distutils/cmd.py__init__zCommand.__init__3s 0/////$ -- DBCC C >W $ $=>> >  !!! |   c|dkr,t|d|z}|t|j|S|St|)Ndry_run_)getattrrAttributeError)rattrmyvals r __getattr__zCommand.__getattr__csK 9  D#*--E}t0$777  && &r cJ|js|d|_dSNr)rfinalize_optionsrs rensure_finalizedzCommand.ensure_finalizedms)~ $  ! ! # # #r c0td|jz)aSet default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, 'initialize_options()' implementations are just a bunch of "self.foo = None" assignments. This method must be implemented by all command classes. ,abstract method -- subclass %s must overriderrr,s rrzCommand.initialize_options  :T^ K   r c0td|jz)aSet final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done. Thus, this is the place to code option dependencies: if 'foo' depends on 'bar', then it is safe to set 'foo' from 'bar' as long as 'foo' still has the same value it was assigned in 'initialize_options()'. This method must be implemented by all command classes. r/r0r,s rr+zCommand.finalize_optionss  :T^ K   r Ncddlm}|d|z}|||ztj|dz}|jD]y\}}}||}|ddkr |dd}t||}||d ||ztjzdS) Nr) longopt_xlatezcommand options for '%s':)levelz =z{} = {}) distutils.fancy_getoptr5get_command_nameannounceloggingINFO user_options translater$format)rheaderindentr5optionr#values r dump_optionszCommand.dump_optionss888888 >043H3H3J3JJF fvoW\ :::$ - X XLFAq%%m44FbzS  D&))E MM&9#3#3FE#B#BB',M W W W W  X Xr c0td|jz)aA command's raison d'etre: carry out the action it exists to perform, controlled by the options initialized in 'initialize_options()', customized by other commands, the setup script, the command-line, and config files, and finalized in 'finalize_options()'. All terminal output and filesystem interaction should be done by 'run()'. This method must be implemented by all command classes. r/r0r,s rrunz Command.runr1r c0tj||dSNr )rmsgr6s rr;zCommand.announces sr ctddlm}|r/t|tjdSdS)z~Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. r)DEBUGN)distutils.debugrLprintsysstdoutflush)rrJrLs r debug_printzCommand.debug_printsM *)))))   #JJJ J         r ct||}|t||||St|ts$t d||||S)Nz'{}' must be a {} (got `{}`))r$setattrrstrrr@)rrCwhatdefaultvals r_ensure_stringlikezCommand._ensure_stringlikesmdF## ; D&' * * *NC%% &.55fdCHH  r c4||d|dS)zWEnsure that 'option' is a string; if not defined, set it to 'default'. stringN)rY)rrCrWs r ensure_stringzCommand.ensure_strings" ':::::r cPt||}|dSt|tr&t||t jd|dSt|t rtd|D}nd}|s#td ||dS)zEnsure that 'option' is a list of strings. If 'option' is currently a string, we split it either on /,\s*/ or /\s+/, so "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become ["foo", "bar", "baz"]. Nz,\s*|\s+c3@K|]}t|tVdSrI)rrU).0vs r z-Command.ensure_string_list..s,99As++999999r Fz)'{}' must be a list of strings (got {!r})) r$rrUrTresplitlistallrr@)rrCrXoks rensure_string_listzCommand.ensure_string_lists dF## ; F S ! !  D&"(;"<"< = = = = =#t$$ 99S99999 *?FFvsSS  r c||||}|"||std|z||fzdSdS)Nzerror in '%s' option: )rYr)rrCtesterrV error_fmtrWrXs r_ensure_tested_stringzCommand._ensure_tested_stringsX%%fdG<< ?66#;;?&)I5&#F  ???r cT||tjjdddS)z5Ensure that 'option' is the name of an existing file.filenamez$'%s' does not exist or is not a fileN)rkospathisfilerrCs rensure_filenamezCommand.ensure_filenames2 "" BGNJ0V     r cT||tjjdddS)Nzdirectory namez)'%s' does not exist or is not a directory)rkrnroisdirrqs rensure_dirnamezCommand.ensure_dirnames4 ""  GM  7      r cHt|dr|jS|jjS)N command_name)hasattrrwr__name__r,s rr:zCommand.get_command_names( 4 ( ( +$ $>* *r c |j|}||D]4\}}t||t ||t||5dS)a>Set the values of any "undefined" options from corresponding option values in some other command object. "Undefined" here means "is None", which is the convention used to indicate that an option has not been changed between 'initialize_options()' and 'finalize_options()'. Usually called from 'finalize_options()' for options that depend on some other command rather than another option of the same command. 'src_cmd' is the other command from which option values will be taken (a command object will be created for it if necessary); the remaining arguments are '(src_option,dst_option)' tuples which mean "take the value of 'src_option' in the 'src_cmd' command object, and copy it to 'dst_option' in the current command object". N)rget_command_objr-r$rT)rsrc_cmd option_pairs src_cmd_obj src_option dst_options rset_undefined_optionszCommand.set_undefined_optionss{'77@@ $$&&&&2 L L "J tZ((0j'+z*J*JKKK L Lr rcd|j||}||S)zWrapper around Distribution's 'get_command_obj()' method: find (create if necessary and 'create' is true) the command object for 'command', call its 'ensure_finalized()' method, and return the finalized command object. )rr{r-)rcommandcreatecmd_objs rget_finalized_commandzCommand.get_finalized_command*s3 #33GVDD  """r rc8|j||SrI)rreinitialize_command)rrreinit_subcommandss rrzCommand.reinitialize_command6s 55g?QRRRr c:|j|dS)zRun some other command: uses the 'run_command()' method of Distribution, which creates and finalizes the command object if necessary and then invokes its 'run()' method. N)r run_command)rrs rrzCommand.run_command9s! %%g.....r chg}|jD]'\}}| ||r||(|S)akDetermine the sub-commands that are relevant in the current distribution (ie., that need to be run). This is based on the 'sub_commands' class attribute: each tuple in that list may include a method that we call to determine if the subcommand needs to be run for the current distribution. Return a list of command names. ) sub_commandsappend)rcommandscmd_namemethods rget_sub_commandszCommand.get_sub_commands@sI $ 1 * * Hf~~)))r cVtjd||dS)Nzwarning: %s: %s )r warningr:)rrJs rwarnz Command.warnOs) ')>)>)@)@#FFFFFr c@tj||||jdSNr")rexecuter")rfuncargsrJr6s rrzCommand.executeRs# T4dl;;;;;;r c>tj|||jdSr)rmkpathr")rnamemodes rrzCommand.mkpathUs!dDL999999r c Ntj|||||j ||jS)zCopy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't define it.)r)r copy_filerr")rinfileoutfile preserve_modepreserve_timeslinkr6s rrzCommand.copy_fileXs9 "     N L    r c Ntj||||||j |jS)z\Copy an entire directory tree respecting verbose, dry-run, and force flags. r)r copy_treerr")rrrrrpreserve_symlinksr6s rrzCommand.copy_treehs9!      NL    r c:tj|||jS)z$Move a file respecting dry-run flag.r)r move_filer")rsrcdstr6s rrzCommand.move_file~s"3T\BBBBr c8ddlm}||||jdS)z2Spawn an external command respecting dry-run flag.r)spawnrN)distutils.spawnrr")rcmd search_pathr6rs rrz Command.spawns3)))))) c; 555555r c Btj|||||j||S)N)r"ownergroup)r make_archiver")r base_namer@root_dirbase_dirrrs rrzCommand.make_archives5(    L    r c|d|z}t|tr|f}n+t|ttfst d|)d|d|}|jstj ||r| ||||dStj |dS)aSpecial case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a different message printed if 'outfile' already exists and is newer than all files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no timestamp checks. Nzskipping %s (inputs unchanged)z9'infiles' must be a string, or a list or tuple of stringszgenerating {} from {}z, ) rrUrdtuplerr@joinrr newer_grouprr debug)rinfilesrrrexec_msgskip_msgr6s r make_filezCommand.make_files  7'AH gs # # YjGGGdE]33 YWXX X  .55gtyy?Q?QRRH : .w@@ LLtXu 5 5 5 5 5 Ih     r )Nr3rI)r)rr*)r)rrNr)rrrr)rr)NNNN)NNr)%ry __module__ __qualname____doc__rrr(r-rr+rErGr<rLr;rRrYr\rgrkrrrur:rrrrrrrrrrrrrrr rr r so  :L---`'''$         X X X X    #*-.    ;;;; *      +++ LLL*SSSS///   GGG<<<<::::TU    (    ,CCCC6666RV     QR      r r )rrOrnrbr<errorsrr3rrrrr _logr r rr rrs  ((((((@@@@@@@@@@@@@@b b b b b b b b b b r