Python django.core.management.base 模块,BaseCommand() 实例源码

我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用django.core.management.base.BaseCommand()

项目:USTC-Software-2017    作者:igemsoftware2017    | 项目源码 | 文件源码
def fetch_command(self, subcommand, command_sets=None):
        """
        Tries to fetch the given subcommand. If it can't be found, prints a
        message with the appropriate command called from the command line
        (e.g. "biohub_cli").
        """

        # Check if the subcommand is available
        try:
            app_name = self.available_commands[subcommand]
        except KeyError:
            sys.stderr.write(
                "Unknown command: %r\nType '%s --help' for usage.\n"
                % (subcommand, self.prog_name))
            sys.exit(1)

        if isinstance(app_name, BaseCommand):
            klass = app_name
        else:
            klass = load_command_class(app_name, subcommand)

        return klass