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


Python optparse.TitledHelpFormatter方法代码示例

本文整理汇总了Python中optparse.TitledHelpFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python optparse.TitledHelpFormatter方法的具体用法?Python optparse.TitledHelpFormatter怎么用?Python optparse.TitledHelpFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在optparse的用法示例。


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

示例1: run

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import TitledHelpFormatter [as 别名]
def run(args=None,settings=None):
    if args is None:
        args = sys.argv
    if settings is None or not isinstance(settings,Settings):
        settings = _get_project_settings()
    install_logger(settings)
    inproject = in_project()
    cmds = _get_all_commands(settings,inproject)
    cmdname = _pop_command_name(args)
    if not cmdname:
        _print_commands(settings, inproject,cmds)
        sys.exit(0)
    elif cmdname not in cmds:
        _print_unknown_command(settings, cmdname, inproject)
        sys.exit(1)
    cmdcls = cmds[cmdname]
    parser = optparse.OptionParser(formatter=optparse.TitledHelpFormatter(),
        conflict_handler='resolve')
    cmd =cmdcls(parser,cmdname)
    parser.usage = 'amipy %s %s '%(cmdname,cmd.syntax())
    parser.description = cmd.long_desc()
    cmd.add_options(parser)
    opts, argvs = parser.parse_args(args=args[1:])
    _execute(cmd,settings,opts, argvs) 
开发者ID:01ly,项目名称:Amipy,代码行数:26,代码来源:cmd.py

示例2: __init__

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import TitledHelpFormatter [as 别名]
def __init__(self, components=(), defaults=None, read_config_files=None,
                 *args, **kwargs):
        """
        `components` is a list of Docutils components each containing a
        ``.settings_spec`` attribute.  `defaults` is a mapping of setting
        default overrides.
        """

        self.lists = {}
        """Set of list-type settings."""

        self.config_files = []
        """List of paths of applied configuration files."""

        optparse.OptionParser.__init__(
            self, option_class=Option, add_help_option=None,
            formatter=optparse.TitledHelpFormatter(width=78),
            *args, **kwargs)
        if not self.version:
            self.version = self.version_template
        # Make an instance copy (it will be modified):
        self.relative_path_settings = list(self.relative_path_settings)
        self.components = (self,) + tuple(components)
        self.populate_from_components(self.components)
        self.set_defaults_from_dict(defaults or {})
        if read_config_files and not self.defaults['_disable_config']:
            try:
                config_settings = self.get_standard_config_settings()
            except ValueError as error:
                self.error(error)
            self.set_defaults_from_dict(config_settings.__dict__) 
开发者ID:skarlekar,项目名称:faces,代码行数:33,代码来源:frontend.py

示例3: __init__

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import TitledHelpFormatter [as 别名]
def __init__(self, components=(), defaults=None, read_config_files=None,
                 *args, **kwargs):
        """
        `components` is a list of Docutils components each containing a
        ``.settings_spec`` attribute.  `defaults` is a mapping of setting
        default overrides.
        """

        self.lists = {}
        """Set of list-type settings."""

        self.config_files = []
        """List of paths of applied configuration files."""

        optparse.OptionParser.__init__(
            self, option_class=Option, add_help_option=None,
            formatter=optparse.TitledHelpFormatter(width=78),
            *args, **kwargs)
        if not self.version:
            self.version = self.version_template
        # Make an instance copy (it will be modified):
        self.relative_path_settings = list(self.relative_path_settings)
        self.components = (self,) + tuple(components)
        self.populate_from_components(self.components)
        self.set_defaults_from_dict(defaults or {})
        if read_config_files and not self.defaults['_disable_config']:
            try:
                config_settings = self.get_standard_config_settings()
            except ValueError, error:
                self.error(error)
            self.set_defaults_from_dict(config_settings.__dict__) 
开发者ID:skarlekar,项目名称:faces,代码行数:33,代码来源:frontend.py

示例4: __init__

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import TitledHelpFormatter [as 别名]
def __init__(self, components=(), defaults=None, read_config_files=None,
                 *args, **kwargs):
        """
        `components` is a list of Docutils components each containing a
        ``.settings_spec`` attribute.  `defaults` is a mapping of setting
        default overrides.
        """

        self.lists = {}
        """Set of list-type settings."""

        self.config_files = []
        """List of paths of applied configuration files."""

        optparse.OptionParser.__init__(
            self, option_class=Option, add_help_option=None,
            formatter=optparse.TitledHelpFormatter(width=78),
            *args, **kwargs)
        if not self.version:
            self.version = self.version_template
        # Make an instance copy (it will be modified):
        self.relative_path_settings = list(self.relative_path_settings)
        self.components = (self,) + tuple(components)
        self.populate_from_components(self.components)
        self.set_defaults_from_dict(defaults or {})
        if read_config_files and not self.defaults['_disable_config']:
            try:
                config_settings = self.get_standard_config_settings()
            except ValueError as error:
                self.error(SafeString(error))
            self.set_defaults_from_dict(config_settings.__dict__) 
开发者ID:QData,项目名称:deepWordBug,代码行数:33,代码来源:frontend.py

示例5: execute

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import TitledHelpFormatter [as 别名]
def execute(argv=None, settings=None):
    if argv is None:
        argv = sys.argv

    if settings is None:
        settings = get_project_settings()
        # set EDITOR from environment if available
        try:
            editor = os.environ['EDITOR']
        except KeyError:
            pass
        else:
            settings['EDITOR'] = editor
    check_deprecated_settings(settings)

    inproject = inside_project()
    cmds = _get_commands_dict(settings, inproject)
    cmdname = _pop_command_name(argv)
    parser = optparse.OptionParser(formatter=optparse.TitledHelpFormatter(), \
                                   conflict_handler='resolve')
    if not cmdname:
        _print_commands(settings, inproject)
        sys.exit(0)
    elif cmdname not in cmds:
        _print_unknown_command(settings, cmdname, inproject)
        sys.exit(2)

    cmd = cmds[cmdname]
    parser.usage = "scrapy %s %s" % (cmdname, cmd.syntax())
    parser.description = cmd.long_desc()
    settings.setdict(cmd.default_settings, priority='command')
    cmd.settings = settings
    cmd.add_options(parser)
    opts, args = parser.parse_args(args=argv[1:])
    _run_print_help(parser, cmd.process_options, args, opts)

    cmd.crawler_process = CrawlerProcess(settings)
    _run_print_help(parser, _run_command, cmd, args, opts)
    sys.exit(cmd.exitcode) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:41,代码来源:cmdline.py

示例6: __init__

# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import TitledHelpFormatter [as 别名]
def __init__(self, components=(), defaults=None, read_config_files=None,
                 *args, **kwargs):
        """
        `components` is a list of Docutils components each containing a
        ``.settings_spec`` attribute.  `defaults` is a mapping of setting
        default overrides.
        """

        self.lists = {}
        """Set of list-type settings."""

        self.config_files = []
        """List of paths of applied configuration files."""

        optparse.OptionParser.__init__(
            self, option_class=Option, add_help_option=None,
            formatter=optparse.TitledHelpFormatter(width=78),
            *args, **kwargs)
        if not self.version:
            self.version = self.version_template
        # Make an instance copy (it will be modified):
        self.relative_path_settings = list(self.relative_path_settings)
        self.components = (self,) + tuple(components)
        self.populate_from_components(self.components)
        self.set_defaults_from_dict(defaults or {})
        if read_config_files and not self.defaults['_disable_config']:
            try:
                config_settings = self.get_standard_config_settings()
            except ValueError, error:
                self.error(SafeString(error))
            self.set_defaults_from_dict(config_settings.__dict__) 
开发者ID:VirtueSecurity,项目名称:aws-extender,代码行数:33,代码来源:frontend.py


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