Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
distutils.tests.test_dist.test_dist Class Reference
Inheritance diagram for distutils.tests.test_dist.test_dist:
Inheritance graph
[legend]
Collaboration diagram for distutils.tests.test_dist.test_dist:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def initialize_options
def __getattr__
def ensure_finalized
def finalize_options
def dump_options
def run
def announce
def debug_print
def ensure_string
def ensure_string_list
def ensure_filename
def ensure_dirname
def get_command_name
def set_undefined_options
def get_finalized_command
def reinitialize_command
def run_command
def get_sub_commands
def warn
def execute
def mkpath
def copy_file
def copy_tree
def move_file
def spawn
def make_archive
def make_file

Public Attributes

 sample_option
 distribution
 verbose
 force
 help
 finalized

Static Public Attributes

list user_options
list sub_commands = []

Detailed Description

Sample distutils extension command.

Definition at line 16 of file test_dist.py.


Member Function Documentation

def distutils.cmd.Command.__getattr__ (   self,
  attr 
) [inherited]

Definition at line 95 of file cmd.py.

00095 
00096     def __getattr__(self, attr):
00097         if attr == 'dry_run':
00098             myval = getattr(self, "_" + attr)
00099             if myval is None:
00100                 return getattr(self.distribution, attr)
00101             else:
00102                 return myval
00103         else:
00104             raise AttributeError(attr)

Here is the call graph for this function:

def distutils.cmd.Command.announce (   self,
  msg,
  level = 1 
) [inherited]
If the current verbosity level is of greater than or equal to
'level' print 'msg' to stdout.

Definition at line 178 of file cmd.py.

00178 
00179     def announce(self, msg, level=1):
00180         """If the current verbosity level is of greater than or equal to
00181         'level' print 'msg' to stdout.
00182         """
00183         log.log(level, msg)

Here is the caller graph for this function:

def distutils.cmd.Command.copy_file (   self,
  infile,
  outfile,
  preserve_mode = 1,
  preserve_times = 1,
  link = None,
  level = 1 
) [inherited]
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.)

Definition at line 342 of file cmd.py.

00342 
00343                   link=None, level=1):
00344         """Copy a file respecting verbose, dry-run and force flags.  (The
00345         former two default to whatever is in the Distribution object, and
00346         the latter defaults to false for commands that don't define it.)"""
00347         return file_util.copy_file(infile, outfile, preserve_mode,
00348                                    preserve_times, not self.force, link,
00349                                    dry_run=self.dry_run)

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.copy_tree (   self,
  infile,
  outfile,
  preserve_mode = 1,
  preserve_times = 1,
  preserve_symlinks = 0,
  level = 1 
) [inherited]
Copy an entire directory tree respecting verbose, dry-run,
and force flags.

Definition at line 351 of file cmd.py.

00351 
00352                    preserve_symlinks=0, level=1):
00353         """Copy an entire directory tree respecting verbose, dry-run,
00354         and force flags.
00355         """
00356         return dir_util.copy_tree(infile, outfile, preserve_mode,
00357                                   preserve_times, preserve_symlinks,
00358                                   not self.force, dry_run=self.dry_run)

Here is the caller graph for this function:

def distutils.cmd.Command.debug_print (   self,
  msg 
) [inherited]
Print 'msg' to stdout if the global DEBUG (taken from the
DISTUTILS_DEBUG environment variable) flag is true.

Definition at line 184 of file cmd.py.

00184 
00185     def debug_print(self, msg):
00186         """Print 'msg' to stdout if the global DEBUG (taken from the
00187         DISTUTILS_DEBUG environment variable) flag is true.
00188         """
00189         from distutils.debug import DEBUG
00190         if DEBUG:
00191             print(msg)
00192             sys.stdout.flush()
00193 

Here is the caller graph for this function:

def distutils.cmd.Command.dump_options (   self,
  header = None,
  indent = "" 
) [inherited]

Definition at line 151 of file cmd.py.

00151 
00152     def dump_options(self, header=None, indent=""):
00153         from distutils.fancy_getopt import longopt_xlate
00154         if header is None:
00155             header = "command options for '%s':" % self.get_command_name()
00156         self.announce(indent + header, level=log.INFO)
00157         indent = indent + "  "
00158         for (option, _, _) in self.user_options:
00159             option = option.translate(longopt_xlate)
00160             if option[-1] == "=":
00161                 option = option[:-1]
00162             value = getattr(self, option)
00163             self.announce(indent + "%s = %s" % (option, value),
00164                           level=log.INFO)

Here is the call graph for this function:

def distutils.cmd.Command.ensure_dirname (   self,
  option 
) [inherited]

Definition at line 257 of file cmd.py.

00257 
00258     def ensure_dirname(self, option):
00259         self._ensure_tested_string(option, os.path.isdir,
00260                                    "directory name",
00261                                    "'%s' does not exist or is not a directory")
00262 

Here is the call graph for this function:

def distutils.cmd.Command.ensure_filename (   self,
  option 
) [inherited]
Ensure that 'option' is the name of an existing file.

Definition at line 251 of file cmd.py.

00251 
00252     def ensure_filename(self, option):
00253         """Ensure that 'option' is the name of an existing file."""
00254         self._ensure_tested_string(option, os.path.isfile,
00255                                    "filename",
00256                                    "'%s' does not exist or is not a file")

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.ensure_finalized (   self) [inherited]

Definition at line 105 of file cmd.py.

00105 
00106     def ensure_finalized(self):
00107         if not self.finalized:
00108             self.finalize_options()
00109         self.finalized = 1

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.ensure_string (   self,
  option,
  default = None 
) [inherited]
Ensure that 'option' is a string; if not defined, set it to
'default'.

Definition at line 217 of file cmd.py.

00217 
00218     def ensure_string(self, option, default=None):
00219         """Ensure that 'option' is a string; if not defined, set it to
00220         'default'.
00221         """
00222         self._ensure_stringlike(option, "string", default)

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.ensure_string_list (   self,
  option 
) [inherited]
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"].

Definition at line 223 of file cmd.py.

00223 
00224     def ensure_string_list(self, option):
00225         """Ensure that 'option' is a list of strings.  If 'option' is
00226         currently a string, we split it either on /,\s*/ or /\s+/, so
00227         "foo bar baz", "foo,bar,baz", and "foo,   bar baz" all become
00228         ["foo", "bar", "baz"].
00229         """
00230         val = getattr(self, option)
00231         if val is None:
00232             return
00233         elif isinstance(val, str):
00234             setattr(self, option, re.split(r',\s*|\s+', val))
00235         else:
00236             if isinstance(val, list):
00237                 ok = all(isinstance(v, str) for v in val)
00238             else:
00239                 ok = False
00240             if not ok:
00241                 raise DistutilsOptionError(
00242                       "'%s' must be a list of strings (got %r)"
00243                       % (option, val))

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.execute (   self,
  func,
  args,
  msg = None,
  level = 1 
) [inherited]

Definition at line 335 of file cmd.py.

00335 
00336     def execute(self, func, args, msg=None, level=1):
00337         util.execute(func, args, msg, dry_run=self.dry_run)

Here is the caller graph for this function:

def distutils.cmd.Command.finalize_options (   self) [inherited]
Set 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.

Reimplemented in setup.AHVDocInstall, distutils.config.PyPIRCCommand, and distutils.command.install_egg_info.install_egg_info.

Definition at line 136 of file cmd.py.

00136 
00137     def finalize_options(self):
00138         """Set final values for all the options that this command supports.
00139         This is always called as late as possible, ie.  after any option
00140         assignments from the command-line or from other commands have been
00141         done.  Thus, this is the place to code option dependencies: if
00142         'foo' depends on 'bar', then it is safe to set 'foo' from 'bar' as
00143         long as 'foo' still has the same value it was assigned in
00144         'initialize_options()'.
00145 
00146         This method must be implemented by all command classes.
00147         """
00148         raise RuntimeError("abstract method -- subclass %s must override"
00149                            % self.__class__)
00150 

Here is the caller graph for this function:

def distutils.cmd.Command.get_command_name (   self) [inherited]

Definition at line 265 of file cmd.py.

00265 
00266     def get_command_name(self):
00267         if hasattr(self, 'command_name'):
00268             return self.command_name
00269         else:
00270             return self.__class__.__name__

Here is the caller graph for this function:

def distutils.cmd.Command.get_finalized_command (   self,
  command,
  create = 1 
) [inherited]
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.

Definition at line 292 of file cmd.py.

00292 
00293     def get_finalized_command(self, command, create=1):
00294         """Wrapper around Distribution's 'get_command_obj()' method: find
00295         (create if necessary and 'create' is true) the command object for
00296         'command', call its 'ensure_finalized()' method, and return the
00297         finalized command object.
00298         """
00299         cmd_obj = self.distribution.get_command_obj(command, create)
00300         cmd_obj.ensure_finalized()
00301         return cmd_obj

Here is the caller graph for this function:

def distutils.cmd.Command.get_sub_commands (   self) [inherited]
Determine 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.

Definition at line 315 of file cmd.py.

00315 
00316     def get_sub_commands(self):
00317         """Determine the sub-commands that are relevant in the current
00318         distribution (ie., that need to be run).  This is based on the
00319         'sub_commands' class attribute: each tuple in that list may include
00320         a method that we call to determine if the subcommand needs to be
00321         run for the current distribution.  Return a list of command names.
00322         """
00323         commands = []
00324         for (cmd_name, method) in self.sub_commands:
00325             if method is None or method(self):
00326                 commands.append(cmd_name)
00327         return commands
00328 

Here is the caller graph for this function:

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.

Reimplemented from distutils.cmd.Command.

Definition at line 23 of file test_dist.py.

00023 
00024     def initialize_options(self):
00025         self.sample_option = None
00026 

def distutils.cmd.Command.make_archive (   self,
  base_name,
  format,
  root_dir = None,
  base_dir = None 
) [inherited]

Definition at line 368 of file cmd.py.

00368 
00369     def make_archive(self, base_name, format, root_dir=None, base_dir=None):
00370         return archive_util.make_archive(base_name, format, root_dir, base_dir,
00371                                          dry_run=self.dry_run)

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.make_file (   self,
  infiles,
  outfile,
  func,
  args,
  exec_msg = None,
  skip_msg = None,
  level = 1 
) [inherited]
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.

Definition at line 373 of file cmd.py.

00373 
00374                   exec_msg=None, skip_msg=None, level=1):
00375         """Special case of 'execute()' for operations that process one or
00376         more input files and generate one output file.  Works just like
00377         'execute()', except the operation is skipped and a different
00378         message printed if 'outfile' already exists and is newer than all
00379         files listed in 'infiles'.  If the command defined 'self.force',
00380         and it is true, then the command is unconditionally run -- does no
00381         timestamp checks.
00382         """
00383         if skip_msg is None:
00384             skip_msg = "skipping %s (inputs unchanged)" % outfile
00385 
00386         # Allow 'infiles' to be a single string
00387         if isinstance(infiles, str):
00388             infiles = (infiles,)
00389         elif not isinstance(infiles, (list, tuple)):
00390             raise TypeError(
00391                   "'infiles' must be a string, or a list or tuple of strings")
00392 
00393         if exec_msg is None:
00394             exec_msg = "generating %s from %s" % (outfile, ', '.join(infiles))
00395 
00396         # If 'outfile' must be regenerated (either because it doesn't
00397         # exist, is out-of-date, or the 'force' flag is true) then
00398         # perform the action that presumably regenerates it
00399         if self.force or dep_util.newer_group(infiles, outfile):
00400             self.execute(func, args, exec_msg, level)
00401         # Otherwise, print the "skip" message
00402         else:
00403             log.debug(skip_msg)
00404 
00405 # XXX 'install_misc' class not currently used -- it was the base class for
00406 # both 'install_scripts' and 'install_data', but they outgrew it.  It might
00407 # still be useful for 'install_headers', though, so I'm keeping it around
00408 # for the time being.

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.mkpath (   self,
  name,
  mode = 0o777 
) [inherited]

Definition at line 338 of file cmd.py.

00338 
00339     def mkpath(self, name, mode=0o777):
00340         dir_util.mkpath(name, mode, dry_run=self.dry_run)

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.move_file (   self,
  src,
  dst,
  level = 1 
) [inherited]
Move a file respecting dry-run flag.

Definition at line 359 of file cmd.py.

00359 
00360     def move_file (self, src, dst, level=1):
00361         """Move a file respecting dry-run flag."""
00362         return file_util.move_file(src, dst, dry_run=self.dry_run)

Here is the caller graph for this function:

def distutils.cmd.Command.reinitialize_command (   self,
  command,
  reinit_subcommands = 0 
) [inherited]

Definition at line 304 of file cmd.py.

00304 
00305     def reinitialize_command(self, command, reinit_subcommands=0):
00306         return self.distribution.reinitialize_command(command,
00307                                                       reinit_subcommands)

Here is the caller graph for this function:

def distutils.cmd.Command.run (   self) [inherited]
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.

Reimplemented in setup.AHVDocInstall, and distutils.command.install_egg_info.install_egg_info.

Definition at line 165 of file cmd.py.

00165 
00166     def run(self):
00167         """A command's raison d'etre: carry out the action it exists to
00168         perform, controlled by the options initialized in
00169         'initialize_options()', customized by other commands, the setup
00170         script, the command-line, and config files, and finalized in
00171         'finalize_options()'.  All terminal output and filesystem
00172         interaction should be done by 'run()'.
00173 
00174         This method must be implemented by all command classes.
00175         """
00176         raise RuntimeError("abstract method -- subclass %s must override"
00177                            % self.__class__)

Here is the caller graph for this function:

def distutils.cmd.Command.run_command (   self,
  command 
) [inherited]
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.

Definition at line 308 of file cmd.py.

00308 
00309     def run_command(self, command):
00310         """Run some other command: uses the 'run_command()' method of
00311         Distribution, which creates and finalizes the command object if
00312         necessary and then invokes its 'run()' method.
00313         """
00314         self.distribution.run_command(command)

Here is the caller graph for this function:

def distutils.cmd.Command.set_undefined_options (   self,
  src_cmd,
  option_pairs 
) [inherited]
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".

Definition at line 271 of file cmd.py.

00271 
00272     def set_undefined_options(self, src_cmd, *option_pairs):
00273         """Set the values of any "undefined" options from corresponding
00274         option values in some other command object.  "Undefined" here means
00275         "is None", which is the convention used to indicate that an option
00276         has not been changed between 'initialize_options()' and
00277         'finalize_options()'.  Usually called from 'finalize_options()' for
00278         options that depend on some other command rather than another
00279         option of the same command.  'src_cmd' is the other command from
00280         which option values will be taken (a command object will be created
00281         for it if necessary); the remaining arguments are
00282         '(src_option,dst_option)' tuples which mean "take the value of
00283         'src_option' in the 'src_cmd' command object, and copy it to
00284         'dst_option' in the current command object".
00285         """
00286         # Option_pairs: list of (src_option, dst_option) tuples
00287         src_cmd_obj = self.distribution.get_command_obj(src_cmd)
00288         src_cmd_obj.ensure_finalized()
00289         for (src_option, dst_option) in option_pairs:
00290             if getattr(self, dst_option) is None:
00291                 setattr(self, dst_option, getattr(src_cmd_obj, src_option))

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.cmd.Command.spawn (   self,
  cmd,
  search_path = 1,
  level = 1 
) [inherited]
Spawn an external command respecting dry-run flag.

Definition at line 363 of file cmd.py.

00363 
00364     def spawn(self, cmd, search_path=1, level=1):
00365         """Spawn an external command respecting dry-run flag."""
00366         from distutils.spawn import spawn
00367         spawn(cmd, search_path, dry_run=self.dry_run)

Here is the caller graph for this function:

def distutils.cmd.Command.warn (   self,
  msg 
) [inherited]

Definition at line 331 of file cmd.py.

00331 
00332     def warn(self, msg):
00333         log.warn("warning: %s: %s\n" %
00334                 (self.get_command_name(), msg))

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 61 of file cmd.py.

Definition at line 92 of file cmd.py.

Definition at line 82 of file cmd.py.

Definition at line 86 of file cmd.py.

Definition at line 24 of file test_dist.py.

list distutils.cmd.Command.sub_commands = [] [static, inherited]

Definition at line 42 of file cmd.py.

Initial value:
[
        ("sample-option=", "S", "help text"),
        ]

Definition at line 19 of file test_dist.py.

Definition at line 76 of file cmd.py.


The documentation for this class was generated from the following file: