當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。