当前位置: 首页>>代码示例>>Python>>正文


Python base.CommandParser类代码示例

本文整理汇总了Python中django.core.management.base.CommandParser的典型用法代码示例。如果您正苦于以下问题:Python CommandParser类的具体用法?Python CommandParser怎么用?Python CommandParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommandParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('-l', '--for-real',
                            dest='for_real',
                            action='store_true',
                            default=False,
                            help="Actually change message flags. Default is a dry run.")

        parser.add_argument('-f', '--flag',
                            dest='flag',
                            type=str,
                            help="The flag to add of remove")

        parser.add_argument('-o', '--op',
                            dest='op',
                            type=str,
                            help="The operation to do: 'add' or 'remove'")

        parser.add_argument('-u', '--until',
                            dest='all_until',
                            type=str,
                            help="Mark all messages <= specific usermessage id")

        parser.add_argument('-m', '--email',
                            dest='email',
                            type=str,
                            help="Email to set messages for")
        self.add_realm_args(parser)
开发者ID:284928489,项目名称:zulip,代码行数:27,代码来源:set_message_flags.py

示例2: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        super().add_arguments(parser)

        parser.add_argument(
            '--strict', '-s',
            action='store_true',
            default=False,
            help='Stop execution in case of errors.')
开发者ID:gnprice,项目名称:zulip,代码行数:8,代码来源:compilemessages.py

示例3: add_arguments

 def add_arguments(self, parser: CommandParser) -> None:
     default_cutoff = time.time() - 60 * 60 * 24 * 30  # 30 days.
     self.add_realm_args(parser, True)
     parser.add_argument('--since',
                         dest='since',
                         type=int,
                         default=default_cutoff,
                         help='The time in epoch since from which to start the dump.')
开发者ID:284928489,项目名称:zulip,代码行数:8,代码来源:dump_messages.py

示例4: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('-s', '--stream',
                            dest='stream',
                            required=True,
                            type=str,
                            help='A stream name.')

        self.add_realm_args(parser, True)
        self.add_user_list_args(parser, all_users_help='Remove all users in realm from this stream.')
开发者ID:brockwhittaker,项目名称:zulip,代码行数:9,代码来源:remove_users_from_stream.py

示例5: add_arguments

 def add_arguments(self, parser: CommandParser) -> None:
     self.add_realm_args(parser)
     parser.add_argument(
         '--lookback-hours',
         dest='lookback_hours',
         type=int,
         help="Period a bit larger than that of the cron job that runs "
              "this command so that the lookback periods are sure to overlap.",
         required=True,
     )
开发者ID:284928489,项目名称:zulip,代码行数:10,代码来源:calculate_first_visible_message_id.py

示例6: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        self.add_realm_args(parser, True)
        self.add_user_list_args(parser, all_users_help="Add all users in realm to these streams.")

        parser.add_argument(
            '-s', '--streams',
            dest='streams',
            type=str,
            required=True,
            help='A comma-separated list of stream names.')
开发者ID:brockwhittaker,项目名称:zulip,代码行数:10,代码来源:add_users_to_streams.py

示例7: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('hipchat_tar', nargs='+',
                            metavar='<hipchat data tarfile>',
                            help="tar of Hipchat data")

        parser.add_argument('--output', dest='output_dir',
                            action="store",
                            help='Directory to write exported data to.')

        parser.formatter_class = argparse.RawTextHelpFormatter
开发者ID:gregmccoy,项目名称:zulip,代码行数:10,代码来源:convert_hipchat_data.py

示例8: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('-f', '--fixture',
                            dest='fixture',
                            type=str,
                            help='The path to the fixture you\'d like to send '
                                 'into Zulip')

        parser.add_argument('-u', '--url',
                            dest='url',
                            type=str,
                            help='The url on your Zulip server that you want '
                                 'to post the fixture to')

        self.add_realm_args(parser, help="Specify which realm/subdomain to connect to; default is zulip")
开发者ID:284928489,项目名称:zulip,代码行数:14,代码来源:send_webhook_fixture_message.py

示例9: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('-f', '--fixture',
                            dest='fixture',
                            type=str,
                            help='The path to the email message you\'d like to send '
                                 'to the email mirror.\n'
                                 'Accepted formats: json or raw email file. '
                                 'See zerver/tests/fixtures/email/ for examples')
        parser.add_argument('-s', '--stream',
                            dest='stream',
                            type=str,
                            help='The name of the stream to which you\'d like to send '
                            'the message. Default: Denmark')

        self.add_realm_args(parser, help="Specify which realm to connect to; default is zulip")
开发者ID:BakerWang,项目名称:zulip,代码行数:15,代码来源:send_to_email_mirror.py

示例10: execute

    def execute(self):
        """
        Given the command-line arguments, this figures out which subcommand is
        being run, creates a parser appropriate to that command, and runs it.
        """
        try:
            subcommand = self.argv[1]
        except IndexError:
            subcommand = 'help'  # Display help if no arguments were given.

        # Preprocess options to extract --settings and --pythonpath.
        # These options could affect the commands that are available, so they
        # must be processed early.
        parser = CommandParser(None, usage="%(prog)s subcommand [options] [args]", add_help=False)
        parser.add_argument('--settings')
        parser.add_argument('--pythonpath')
        parser.add_argument('args', nargs='*')  # catch-all
        try:
            options, args = parser.parse_known_args(self.argv[2:])
            handle_default_options(options)
        except CommandError:
            pass  # Ignore any option errors at this point.

        no_settings_commands = [
            'help', 'version', '--help', '--version', '-h',
            'compilemessages', 'makemessages',
            'startapp', 'startproject',
        ]

        try:
            settings.INSTALLED_APPS
        except ImproperlyConfigured as exc:
            self.settings_exception = exc
            # A handful of built-in management commands work without settings.
            # Load the default settings -- where INSTALLED_APPS is empty.
            if subcommand in no_settings_commands:
                settings.configure()

        if settings.configured:
            django.setup()

        self.autocomplete()

        if subcommand == 'help':
            if '--commands' in args:
                sys.stdout.write(self.main_help_text(commands_only=True) + '\n')
            elif len(options.args) < 1:
                sys.stdout.write(self.main_help_text() + '\n')
            else:
                self.fetch_command(options.args[0]).print_help(self.prog_name, options.args[0])
        # Special-cases: We want 'django-admin --version' and
        # 'django-admin --help' to work, for backwards compatibility.
        elif subcommand == 'version' or self.argv[1:] == ['--version']:
            sys.stdout.write(django.get_version() + '\n')
        elif self.argv[1:] in (['--help'], ['-h']):
            sys.stdout.write(self.main_help_text() + '\n')
        else:
            self.fetch_command(subcommand).run_from_argv(self.argv)
开发者ID:AaronLaw,项目名称:django,代码行数:58,代码来源:__init__.py

示例11: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('slack_data_zip', nargs='+',
                            metavar='<slack data zip>',
                            help="Zipped slack data")

        parser.add_argument('realm_name', metavar='<realm_name>',
                            type=str, help="Realm Name")

        parser.add_argument('--token', metavar='<slack_token>',
                            type=str, help='Slack legacy token of the organsation')

        parser.add_argument('--output', dest='output_dir',
                            action="store", default=None,
                            help='Directory to write exported data to.')
        parser.formatter_class = argparse.RawTextHelpFormatter
开发者ID:gnprice,项目名称:zulip,代码行数:15,代码来源:convert_slack_data.py

示例12: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('slack_data_zip', nargs='+',
                            metavar='<slack data zip>',
                            help="Zipped slack data")

        parser.add_argument('--token', metavar='<slack_token>',
                            type=str, help='Slack legacy token of the organsation')

        parser.add_argument('--output', dest='output_dir',
                            action="store", default=None,
                            help='Directory to write exported data to.')

        parser.add_argument('--threads',
                            dest='threads',
                            action="store",
                            default=6,
                            help='Threads to use in exporting UserMessage objects in parallel')

        parser.formatter_class = argparse.RawTextHelpFormatter
开发者ID:284928489,项目名称:zulip,代码行数:19,代码来源:convert_slack_data.py

示例13: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('--destroy-rebuild-database',
                            dest='destroy_rebuild_database',
                            default=False,
                            action="store_true",
                            help='Destroys and rebuilds the databases prior to import.')

        parser.add_argument('--import-into-nonempty',
                            dest='import_into_nonempty',
                            default=False,
                            action="store_true",
                            help='Import into an existing nonempty database.')

        parser.add_argument('subdomain', metavar='<subdomain>',
                            type=str, help="Subdomain")

        parser.add_argument('export_paths', nargs='+',
                            metavar='<export path>',
                            help="list of export directories to import")
        parser.formatter_class = argparse.RawTextHelpFormatter
开发者ID:akashnimare,项目名称:zulip,代码行数:20,代码来源:import.py

示例14: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('addrport', nargs="?", type=str,
                            help='[optional port number or ipaddr:port]\n '
                                 '(use multiple ports to start multiple servers)')

        parser.add_argument('--nokeepalive', action='store_true',
                            dest='no_keep_alive', default=False,
                            help="Tells Tornado to NOT keep alive http connections.")

        parser.add_argument('--noxheaders', action='store_false',
                            dest='xheaders', default=True,
                            help="Tells Tornado to NOT override remote IP with X-Real-IP.")
开发者ID:gnprice,项目名称:zulip,代码行数:12,代码来源:runtornado.py

示例15: add_arguments

    def add_arguments(self, parser: CommandParser) -> None:
        parser.add_argument('gitter_data', nargs='+',
                            metavar='<gitter data>',
                            help="Gitter data in json format")

        parser.add_argument('--output', dest='output_dir',
                            action="store", default=None,
                            help='Directory to write exported data to.')

        parser.add_argument('--threads',
                            dest='threads',
                            action="store",
                            default=6,
                            help='Threads to download avatars and attachments faster')

        parser.formatter_class = argparse.RawTextHelpFormatter
开发者ID:akashnimare,项目名称:zulip,代码行数:16,代码来源:convert_gitter_data.py


注:本文中的django.core.management.base.CommandParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。