AlkantarClanX12

Your IP : 18.117.158.10


Current Path : /opt/alt/python34/lib64/python3.4/distutils/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/distutils/__pycache__/cmd.cpython-34.pyc

�
h f�J�@s�dZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZddlmZGdd�d�Z
Gdd	�d	e
�ZdS)
ztdistutils.cmd

Provides the Command class, the base class for the command classes
in the distutils.command package.
�N)�DistutilsOptionError)�util�dir_util�	file_util�archive_util�dep_util)�logc@s�eZdZdZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
dd�Z
dd�Zddd�Zdd�Z
ddd�Zddd�Zdd�Zddd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zdd'd(�Zd)d*d+�Zd,d-�Zd.d/�Zd0d1�Zddd2d3�Zd4d5d6�Zddddd7d8�Zddd)dd9d:�Zdd;d<�Zddd=d>�Z ddddd?d@�Z!ddddAdB�Z"dS)C�Commanda}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.
    cCs�ddlm}t||�s.td��n|jtkrLtd��n||_|j�d|_	|j
|_
d|_d|_d|_
dS)z�Create 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)Zdistutils.distr
�
isinstance�	TypeError�	__class__r	�RuntimeError�distribution�initialize_optionsZ_dry_run�verbose�force�help�	finalized)�selfZdistr
�r�2/opt/alt/python34/lib64/python3.4/distutils/cmd.py�__init__/s	

			zCommand.__init__cCsR|dkrBt|d|�}|dkr;t|j|�S|Snt|��dS)N�dry_run�_)�getattrr�AttributeError)r�attrZmyvalrrr�__getattr___szCommand.__getattr__cCs#|js|j�nd|_dS)N�)r�finalize_options)rrrr�ensure_finalizedis	
zCommand.ensure_finalizedcCstd|j��dS)a�Set 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.
        z,abstract method -- subclass %s must overrideN)rr
)rrrrr{s
zCommand.initialize_optionscCstd|j��dS)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.
        z,abstract method -- subclass %s must overrideN)rr
)rrrrr �szCommand.finalize_optionsN�cCs�ddlm}|dkr/d|j�}n|j||dtj�|d}x|jD]t\}}}|j|�}|d	dkr�|dd
�}nt||�}|j|d||fdtj�q]WdS)Nr)�
longopt_xlatezcommand options for '%s':�levelz  r�=z%s = %s���r&)	Zdistutils.fancy_getoptr#�get_command_name�announcer�INFO�user_options�	translater)r�header�indentr#�optionr�valuerrr�dump_options�s
zCommand.dump_optionscCstd|j��dS)a�A 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.
        z,abstract method -- subclass %s must overrideN)rr
)rrrr�run�s
zCommand.runrcCstj||�dS)zmIf the current verbosity level is of greater than or equal to
        'level' print 'msg' to stdout.
        N)r)r�msgr$rrrr(�szCommand.announcecCs4ddlm}|r0t|�tjj�ndS)z~Print 'msg' to stdout if the global DEBUG (taken from the
        DISTUTILS_DEBUG environment variable) flag is true.
        r)�DEBUGN)Zdistutils.debugr3�print�sys�stdout�flush)rr2r3rrr�debug_print�s
zCommand.debug_printcCs^t||�}|dkr/t|||�|St|t�sZtd|||f��n|S)Nz'%s' must be a %s (got `%s`))r�setattrr�strr)rr.�what�default�valrrr�_ensure_stringlike�szCommand._ensure_stringlikecCs|j|d|�dS)zWEnsure that 'option' is a string; if not defined, set it to
        'default'.
        �stringN)r>)rr.r<rrr�
ensure_string�szCommand.ensure_stringcCs�t||�}|dkrdSt|t�rMt||tjd|��nPt|t�rxtdd�|D��}nd}|s�td||f��ndS)z�Ensure 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+css|]}t|t�VqdS)N)rr:)�.0�vrrr�	<genexpr>�sz-Command.ensure_string_list.<locals>.<genexpr>Fz''%s' must be a list of strings (got %r))	rrr:r9�re�split�list�allr)rr.r=�okrrr�ensure_string_list�szCommand.ensure_string_listcCsO|j|||�}|dk	rK||�rKtd|||f��ndS)Nzerror in '%s' option: )r>r)rr.Ztesterr;Z	error_fmtr<r=rrr�_ensure_tested_string�s
zCommand._ensure_tested_stringcCs |j|tjjdd�dS)z5Ensure that 'option' is the name of an existing file.�filenamez$'%s' does not exist or is not a fileN)rJ�os�path�isfile)rr.rrr�ensure_filename�szCommand.ensure_filenamecCs |j|tjjdd�dS)Nzdirectory namez)'%s' does not exist or is not a directory)rJrLrM�isdir)rr.rrr�ensure_dirnameszCommand.ensure_dirnamecCs$t|d�r|jS|jjSdS)N�command_name)�hasattrrRr
�__name__)rrrrr'	szCommand.get_command_namecGsh|jj|�}|j�xE|D]=\}}t||�dkr#t||t||��q#q#WdS)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)r�get_command_objr!rr9)rZsrc_cmdZoption_pairsZsrc_cmd_objZ
src_optionZ
dst_optionrrr�set_undefined_optionss

zCommand.set_undefined_optionscCs#|jj||�}|j�|S)z�Wrapper 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.
        )rrUr!)r�command�createZcmd_objrrr�get_finalized_command$s
zCommand.get_finalized_commandrcCs|jj||�S)N)r�reinitialize_command)rrWZreinit_subcommandsrrrrZ0szCommand.reinitialize_commandcCs|jj|�dS)z�Run 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)rrWrrrr[4szCommand.run_commandcCsLg}x?|jD]4\}}|dks4||�r|j|�qqW|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.
        N)�sub_commands�append)rZcommandsZcmd_name�methodrrr�get_sub_commands;s
zCommand.get_sub_commandscCs!tjd|j�|f�dS)Nzwarning: %s: %s
)r�warnr')rr2rrrr`Ks	zCommand.warncCs tj|||d|j�dS)Nr)r�executer)r�func�argsr2r$rrrraOszCommand.executei�cCstj||d|j�dS)Nr)r�mkpathr)r�name�moderrrrdRszCommand.mkpathc	Cs)tj|||||j|d|j�S)z�Copy 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)r�infile�outfile�
preserve_mode�preserve_times�linkr$rrrrgUszCommand.copy_filec	Cs)tj||||||jd|j�S)z\Copy an entire directory tree respecting verbose, dry-run,
        and force flags.
        r)r�	copy_treerr)rrhrirjrkZpreserve_symlinksr$rrrrm^szCommand.copy_treecCstj||d|j�S)z$Move a file respecting dry-run flag.r)r�	move_filer)r�srcZdstr$rrrrngszCommand.move_filecCs*ddlm}|||d|j�dS)z2Spawn an external command respecting dry-run flag.r)�spawnrN)Zdistutils.spawnrpr)r�cmdZsearch_pathr$rprrrrpksz
Command.spawncCs+tj||||d|jd|d|�S)Nr�owner�group)r�make_archiver)rZ	base_name�formatZroot_dirZbase_dirrrrsrrrrtps	zCommand.make_archivecCs�|dkrd|}nt|t�r4|f}n$t|ttf�sXtd��n|dkr�d|dj|�f}n|js�tj||�r�|j	||||�n
t
j|�dS)a�Special 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 %s from %sz, )rr:rF�tupler�joinrrZnewer_grouprar�debug)rZinfilesrirbrcZexec_msgZskip_msgr$rrr�	make_filevs

zCommand.make_file)#rT�
__module__�__qualname__�__doc__r\rrr!rr r0r1r(r8r>r@rIrJrOrQr'rVrYrZr[r_r`rardrgrmrnrprtryrrrrr	sF0



r	c@sOeZdZdZdgZdd�Zdd�Zd	d
�Zdd�Zd
S)�install_miscz{Common base class for installing some files in a subdirectory.
    Currently used by install_data and install_scripts.
    �install-dir=�d�!directory to install the files tocCsd|_g|_dS)N)�install_dir�outfiles)rrrrr�s	zinstall_misc.initialize_optionscCs|jd|df�dS)NZinstallr�)rV)r�dirnamerrr�_install_dir_from�szinstall_misc._install_dir_fromcCsmg|_|sdS|j|j�xC|D];}|j||j�|jjtjj|j|��q*WdS)N)r�rdr�rgr]rLrMrw)rZfilelist�frrr�_copy_files�s	
zinstall_misc._copy_filescCs|jS)N)r�)rrrr�get_outputs�szinstall_misc.get_outputsN)r~rr�)	rTrzr{r|r*rr�r�r�rrrrr}�s		r})r|r5rLrDZdistutils.errorsrZ	distutilsrrrrrrr	r}rrrr�<module>s$(��