當前位置: 首頁>>代碼示例>>Python>>正文


Python cmd.Command方法代碼示例

本文整理匯總了Python中distutils.cmd.Command方法的典型用法代碼示例。如果您正苦於以下問題:Python cmd.Command方法的具體用法?Python cmd.Command怎麽用?Python cmd.Command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在distutils.cmd的用法示例。


在下文中一共展示了cmd.Command方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: combine_commands

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def combine_commands(*commands):
    """Return a Command that combines several commands."""

    class CombinedCommand(Command):
        user_options = []

        def initialize_options(self):
            self.commands = []
            for C in commands:
                self.commands.append(C(self.distribution))
            for c in self.commands:
                c.initialize_options()

        def finalize_options(self):
            for c in self.commands:
                c.finalize_options()

        def run(self):
            for c in self.commands:
                c.run()
    return CombinedCommand 
開發者ID:jupyter-widgets,項目名稱:jupyterlab-sidecar,代碼行數:23,代碼來源:setupbase.py

示例2: ensure_targets

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def ensure_targets(targets):
    """Return a Command that checks that certain files exist.

    Raises a ValueError if any of the files are missing.

    Note: The check is skipped if the `--skip-npm` flag is used.
    """

    class TargetsCheck(BaseCommand):
        def run(self):
            if skip_npm:
                log.info('Skipping target checks')
                return
            missing = [t for t in targets if not os.path.exists(t)]
            if missing:
                raise ValueError(('missing files: %s' % missing))

    return TargetsCheck


# `shutils.which` function copied verbatim from the Python-3.3 source. 
開發者ID:jupyter-widgets,項目名稱:jupyterlab-sidecar,代碼行數:23,代碼來源:setupbase.py

示例3: combine_commands

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def combine_commands(*commands):
    """Return a Command that combines several commands."""

    class CombinedCommand(Command):
        user_options = []

        def initialize_options(self):
            self.commands = []
            for C in commands:
                self.commands.append(C(self.distribution))
            for c in self.commands:
                c.initialize_options()

        def finalize_options(self):
            for c in self.commands:
                c.finalize_options()

        def run(self):
            for c in self.commands:
                c.run()

    return CombinedCommand 
開發者ID:IBM,項目名稱:jupyterlab-s3-browser,代碼行數:24,代碼來源:setupbase.py

示例4: ensure_targets

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def ensure_targets(targets):
    """Return a Command that checks that certain files exist.

    Raises a ValueError if any of the files are missing.

    Note: The check is skipped if the `--skip-npm` flag is used.
    """

    class TargetsCheck(BaseCommand):
        def run(self):
            if skip_npm:
                log.info("Skipping target checks")
                return
            missing = [t for t in targets if not os.path.exists(t)]
            if missing:
                raise ValueError(("missing files: %s" % missing))

    return TargetsCheck


# `shutils.which` function copied verbatim from the Python-3.3 source. 
開發者ID:IBM,項目名稱:jupyterlab-s3-browser,代碼行數:23,代碼來源:setupbase.py

示例5: _parse_command_opts

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def _parse_command_opts(self, parser, args):
        """Parse the command-line options for a single command.
        'parser' must be a FancyGetopt instance; 'args' must be the list
        of arguments, starting with the current command (whose options
        we are about to parse).  Returns a new version of 'args' with
        the next command at the front of the list; will be the empty
        list if there are no more commands on the command line.  Returns
        None if the user asked for help on this command.
        """
        # late import because of mutual dependence between these modules
        from distutils.cmd import Command

        # Pull the current command from the head of the command line
        command = args[0]
        if not command_re.match(command):
            raise SystemExit, "invalid command name '%s'" % command
        self.commands.append(command)

        # Dig up the command class that implements this command, so we
        # 1) know that it's a valid command, and 2) know which options
        # it takes.
        try:
            cmd_class = self.get_command_class(command)
        except DistutilsModuleError, msg:
            raise DistutilsArgError, msg

        # Require that the command class be derived from Command -- want
        # to be sure that the basic "command" interface is implemented. 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:30,代碼來源:dist.py

示例6: finalize_options

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def finalize_options(self):
        """Set final values for all the options on the Distribution
        instance, analogous to the .finalize_options() method of Command
        objects.
        """
        for attr in ('keywords', 'platforms'):
            value = getattr(self.metadata, attr)
            if value is None:
                continue
            if isinstance(value, str):
                value = [elm.strip() for elm in value.split(',')]
                setattr(self.metadata, attr, value) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:14,代碼來源:dist.py

示例7: get_command_list

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def get_command_list(self):
        """Get a list of (command, description) tuples.
        The list is divided into "standard commands" (listed in
        distutils.command.__all__) and "extra commands" (mentioned in
        self.cmdclass, but not a standard command).  The descriptions come
        from the command class attribute 'description'.
        """
        # Currently this is only used on Mac OS, for the Mac-only GUI
        # Distutils interface (by Jack Jansen)

        import distutils.command
        std_commands = distutils.command.__all__
        is_std = {}
        for cmd in std_commands:
            is_std[cmd] = 1

        extra_commands = []
        for cmd in self.cmdclass.keys():
            if not is_std.get(cmd):
                extra_commands.append(cmd)

        rv = []
        for cmd in (std_commands + extra_commands):
            klass = self.cmdclass.get(cmd)
            if not klass:
                klass = self.get_command_class(cmd)
            try:
                description = klass.description
            except AttributeError:
                description = "(no description available)"
            rv.append((cmd, description))
        return rv

    # -- Command class/object methods ---------------------------------- 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:36,代碼來源:dist.py

示例8: reinitialize_command

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def reinitialize_command(self, command, reinit_subcommands=0):
        """Reinitializes a command to the state it was in when first
        returned by 'get_command_obj()': ie., initialized but not yet
        finalized.  This provides the opportunity to sneak option
        values in programmatically, overriding or supplementing
        user-supplied values from the config files and command line.
        You'll have to re-finalize the command object (by calling
        'finalize_options()' or 'ensure_finalized()') before using it for
        real.

        'command' should be a command name (string) or command object.  If
        'reinit_subcommands' is true, also reinitializes the command's
        sub-commands, as declared by the 'sub_commands' class attribute (if
        it has one).  See the "install" command for an example.  Only
        reinitializes the sub-commands that actually matter, ie. those
        whose test predicates return true.

        Returns the reinitialized command object.
        """
        from distutils.cmd import Command
        if not isinstance(command, Command):
            command_name = command
            command = self.get_command_obj(command_name)
        else:
            command_name = command.get_command_name()

        if not command.finalized:
            return command
        command.initialize_options()
        command.finalized = 0
        self.have_run[command_name] = 0
        self._set_command_options(command)

        if reinit_subcommands:
            for sub in command.get_sub_commands():
                self.reinitialize_command(sub, reinit_subcommands)

        return command

    # -- Methods that operate on the Distribution ---------------------- 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:42,代碼來源:dist.py

示例9: sphinx_builder

# 需要導入模塊: from distutils import cmd [as 別名]
# 或者: from distutils.cmd import Command [as 別名]
def sphinx_builder():
    try:
        from sphinx.setup_command import BuildDoc
    except ImportError:

        class NoSphinx(Command):

            user_options = []

            def initialize_options(self):
                raise RuntimeError('Sphinx documentation is not installed, run: pip install sphinx')

        return NoSphinx

    class BuildSphinxDocs(BuildDoc):

        def run(self):
            if self.builder == 'doctest':
                import sphinx.ext.doctest as doctest
                # Capture the DocTestBuilder class in order to return the total
                # number of failures when exiting
                ref = capture_objs(doctest.DocTestBuilder)
                BuildDoc.run(self)
                errno = ref[-1].total_failures
                sys.exit(errno)
            else:
                BuildDoc.run(self)

    return BuildSphinxDocs 
開發者ID:zalando,項目名稱:spilo,代碼行數:31,代碼來源:setup.py


注:本文中的distutils.cmd.Command方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。