Your IP : 216.73.216.181
�
��f[Jc@s�dZddlZddlZddlZddlmZddlmZmZm Z m
Z
mZddlmZGdd�d�Z
Gdd �d e
�ZdS(
utdistutils.cmd
Provides the Command class, the base class for the command classes
in the distutils.command package.
iN(uDistutilsOptionError(uutiludir_utilu file_utiluarchive_utiludep_util(ulogcBs�|EeZdZdZgZdd�Zdd�Zdd�Zdd �Zd
d�Z dBdd
d�Zdd�Zddd�Z
dd�ZdBdd�ZdBdd�Zdd�ZdBdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zdd&d'�Zd(d)d*�Zd+d,�Zd-d.�Zd/d0�ZdBdd1d2�Zd3d4d5�ZdddBdd6d7�Zddd(dd8d9�Zdd:d;�Z ddd<d=�Z!dBdBd>d?�Z"dBdBdd@dA�Z#dBS(CuCommandu}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(u�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.
i(uDistributionu$dist must be a Distribution instanceuCommand is an abstract classN(udistutils.distuDistributionu
isinstanceu TypeErroru __class__uCommanduRuntimeErrorudistributionuinitialize_optionsuNoneu_dry_runuverboseuforceuhelpu finalized(uselfudistuDistribution((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu__init__/s
uCommand.__init__cCsR|dkrBt|d|�}|dkr;t|j|�S|Snt|��dS(Nudry_runu_(ugetattruNoneudistributionuAttributeError(uselfuattrumyval((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu__getattr___suCommand.__getattr__cCs#|js|j�nd|_dS(Ni(u finalizedufinalize_options(uself((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuensure_finalizedis
uCommand.ensure_finalizedcCstd|j��dS(u�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.
u,abstract method -- subclass %s must overrideN(uRuntimeErroru __class__(uself((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuinitialize_options{s
uCommand.initialize_optionscCstd|j��dS(uSet 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.
u,abstract method -- subclass %s must overrideN(uRuntimeErroru __class__(uself((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyufinalize_options�suCommand.finalize_optionsucCs�ddlm}|dkr/d|j�}n|j||dtj�|d}x|jD]t\}}}|j|�}|d dkr�|dd
�}nt ||�}|j|d||fdtj�q]WdS(Ni(u
longopt_xlateucommand options for '%s':ulevelu iu=u%s = %si����i����(
udistutils.fancy_getoptu
longopt_xlateuNoneuget_command_nameuannounceuloguINFOuuser_optionsu translateugetattr(uselfuheaderuindentu
longopt_xlateuoptionu_uvalue((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyudump_options�s
uCommand.dump_optionscCstd|j��dS(u�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.
u,abstract method -- subclass %s must overrideN(uRuntimeErroru __class__(uself((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyurun�s
uCommand.runicCstj||�dS(umIf the current verbosity level is of greater than or equal to
'level' print 'msg' to stdout.
N(ulog(uselfumsgulevel((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuannounce�suCommand.announcecCs4ddlm}|r0t|�tjj�ndS(u~Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.
i(uDEBUGN(udistutils.debuguDEBUGuprintusysustdoutuflush(uselfumsguDEBUG((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyudebug_print�s
uCommand.debug_printcCs^t||�}|dkr/t|||�|St|t�sZtd|||f��n|S(Nu'%s' must be a %s (got `%s`)(ugetattruNoneusetattru
isinstanceustruDistutilsOptionError(uselfuoptionuwhatudefaultuval((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu_ensure_stringlike�suCommand._ensure_stringlikecCs|j|d|�dS(uWEnsure that 'option' is a string; if not defined, set it to
'default'.
ustringN(u_ensure_stringlike(uselfuoptionudefault((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu
ensure_string�suCommand.ensure_stringcCs�t||�}|dkrdSt|t�rMt||tjd|��nPt|t�rxtdd�|D��}nd}|s�t
d||f��ndS(u�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"].
Nu,\s*|\s+css|]}t|t�VqdS(N(u
isinstanceustr(u.0uv((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu <genexpr>�su-Command.ensure_string_list.<locals>.<genexpr>u''%s' must be a list of strings (got %r)F(ugetattruNoneu
isinstanceustrusetattrureusplitulistualluFalseuDistutilsOptionError(uselfuoptionuvaluok((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuensure_string_list�suCommand.ensure_string_listcCsO|j|||�}|dk rK||�rKtd|||f��ndS(Nuerror in '%s' option: (u_ensure_stringlikeuNoneuDistutilsOptionError(uselfuoptionutesteruwhatu error_fmtudefaultuval((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu_ensure_tested_string�s
uCommand._ensure_tested_stringcCs |j|tjjdd�dS(u5Ensure that 'option' is the name of an existing file.ufilenameu$'%s' does not exist or is not a fileN(u_ensure_tested_stringuosupathuisfile(uselfuoption((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuensure_filename�suCommand.ensure_filenamecCs |j|tjjdd�dS(Nudirectory nameu)'%s' does not exist or is not a directory(u_ensure_tested_stringuosupathuisdir(uselfuoption((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuensure_dirnamesuCommand.ensure_dirnamecCs$t|d�r|jS|jjSdS(Nucommand_name(uhasattrucommand_nameu __class__u__name__(uself((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuget_command_name suCommand.get_command_namecGsh|jj|�}|j�xE|D]=\}}t||�dkr#t||t||��q#q#WdS(u>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(udistributionuget_command_objuensure_finalizedugetattruNoneusetattr(uselfusrc_cmduoption_pairsusrc_cmd_obju
src_optionu
dst_option((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuset_undefined_optionss
uCommand.set_undefined_optionscCs#|jj||�}|j�|S(u�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.
(udistributionuget_command_objuensure_finalized(uselfucommanducreateucmd_obj((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuget_finalized_command$s
uCommand.get_finalized_commandicCs|jj||�S(N(udistributionureinitialize_command(uselfucommandureinit_subcommands((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyureinitialize_command0suCommand.reinitialize_commandcCs|jj|�dS(u�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(udistributionurun_command(uselfucommand((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyurun_command4suCommand.run_commandcCsLg}x?|jD]4\}}|dks4||�r|j|�qqW|S(ukDetermine 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(usub_commandsuNoneuappend(uselfucommandsucmd_nameumethod((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuget_sub_commands;s
uCommand.get_sub_commandscCs!tjd|j�|f�dS(Nuwarning: %s: %s
(uloguwarnuget_command_name(uselfumsg((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuwarnKs uCommand.warncCs tj|||d|j�dS(Nudry_run(uutiluexecuteudry_run(uselfufuncuargsumsgulevel((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuexecuteOsuCommand.executei�cCstj||d|j�dS(Nudry_run(udir_utilumkpathudry_run(uselfunameumode((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyumkpathRsuCommand.mkpathc Cs)tj|||||j|d|j�S(u�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.)udry_run(u file_utilu copy_fileuforceudry_run(uselfuinfileuoutfileu
preserve_modeupreserve_timesulinkulevel((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu copy_fileUsuCommand.copy_filec Cs)tj||||||jd|j�S(u\Copy an entire directory tree respecting verbose, dry-run,
and force flags.
udry_run(udir_utilu copy_treeuforceudry_run(uselfuinfileuoutfileu
preserve_modeupreserve_timesupreserve_symlinksulevel((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu copy_tree^suCommand.copy_treecCstj||d|j�S(u$Move a file respecting dry-run flag.udry_run(u file_utilu move_fileudry_run(uselfusrcudstulevel((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu move_filegsuCommand.move_filecCs*ddlm}|||d|j�dS(u2Spawn an external command respecting dry-run flag.i(uspawnudry_runN(udistutils.spawnuspawnudry_run(uselfucmdusearch_pathuleveluspawn((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuspawnksu
Command.spawncCstj||||d|j�S(Nudry_run(uarchive_utilumake_archiveudry_run(uselfu base_nameuformaturoot_dirubase_dir((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyumake_archivepsuCommand.make_archivecCs�|dkrd|}nt|t�r4|f}n$t|ttf�sXtd��n|dkr�d|dj|�f}n|js�tj ||�r�|j
||||�n
tj|�dS(u�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.
uskipping %s (inputs unchanged)u9'infiles' must be a string, or a list or tuple of stringsugenerating %s from %su, N(
uNoneu
isinstanceustrulistutupleu TypeErrorujoinuforceudep_utilunewer_groupuexecuteulogudebug(uselfuinfilesuoutfileufuncuargsuexec_msguskip_msgulevel((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu make_filets
uCommand.make_fileN($u__name__u
__module__u__qualname__u__doc__usub_commandsu__init__u__getattr__uensure_finalizeduinitialize_optionsufinalize_optionsuNoneudump_optionsurunuannounceudebug_printu_ensure_stringlikeu
ensure_stringuensure_string_listu_ensure_tested_stringuensure_filenameuensure_dirnameuget_command_nameuset_undefined_optionsuget_finalized_commandureinitialize_commandurun_commanduget_sub_commandsuwarnuexecuteumkpathu copy_fileu copy_treeu move_fileuspawnumake_archiveu make_file(u
__locals__((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuCommandsD0
uCommandcBsS|EeZdZdZdgZdd�Zdd�Zd d
�Zdd�Zd
S(uinstall_miscu{Common base class for installing some files in a subdirectory.
Currently used by install_data and install_scripts.
uinstall-dir=udu!directory to install the files tocCsd|_g|_dS(N(uNoneuinstall_diruoutfiles(uself((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuinitialize_options�s uinstall_misc.initialize_optionscCs|jd|df�dS(Nuinstalluinstall_dir(uset_undefined_options(uselfudirname((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu_install_dir_from�suinstall_misc._install_dir_fromcCsmg|_|sdS|j|j�xC|D];}|j||j�|jjtjj|j|��q*WdS(N(uoutfilesumkpathuinstall_diru copy_fileuappenduosupathujoin(uselfufilelistuf((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu_copy_files�s
uinstall_misc._copy_filescCs|jS(N(uoutfiles(uself((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuget_outputs�suinstall_misc.get_outputsN(uinstall-dir=udu!directory to install the files to( u__name__u
__module__u__qualname__u__doc__uuser_optionsuinitialize_optionsu_install_dir_fromu_copy_filesuget_outputs(u
__locals__((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyuinstall_misc�s uinstall_misc(u__doc__usysuosureudistutils.errorsuDistutilsOptionErroru distutilsuutiludir_utilu file_utiluarchive_utiludep_utiluloguCommanduinstall_misc(((u2/opt/alt/python33/lib64/python3.3/distutils/cmd.pyu<module>s$(��
?>