本文整理汇总了Python中optparse.IndentedHelpFormatter方法的典型用法代码示例。如果您正苦于以下问题:Python optparse.IndentedHelpFormatter方法的具体用法?Python optparse.IndentedHelpFormatter怎么用?Python optparse.IndentedHelpFormatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类optparse
的用法示例。
在下文中一共展示了optparse.IndentedHelpFormatter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cmd_install_module
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import IndentedHelpFormatter [as 别名]
def cmd_install_module(params):
formatter = optparse.IndentedHelpFormatter()
formatter.set_long_opt_delimiter(' ')
usage = '%prog install-module [options]'
parser = optparse.OptionParser(usage=usage, formatter=formatter)
parser.add_option('--modules-directory', metavar='DIRECTORY',
default=apxs_config.LIBEXECDIR)
(options, args) = parser.parse_args(params)
if len(args) != 0:
parser.error('Incorrect number of arguments.')
target = os.path.abspath(os.path.join(options.modules_directory,
os.path.basename(MOD_WSGI_SO)))
shutil.copyfile(where(), target)
if _py_dylib:
print('LoadFile "%s"' % _py_dylib)
print('LoadModule wsgi_module "%s"' % target)
print('WSGIPythonHome "%s"' % os.path.normpath(sys.prefix))
示例2: __init__
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import IndentedHelpFormatter [as 别名]
def __init__(self, *args, **kwargs):
# help position must be aligned with __init__.parseopts.description
kwargs['max_help_position'] = 30
kwargs['indent_increment'] = 1
kwargs['width'] = get_terminal_size()[0] - 2
optparse.IndentedHelpFormatter.__init__(self, *args, **kwargs)
示例3: expand_default
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import IndentedHelpFormatter [as 别名]
def expand_default(self, option):
if self.parser is not None:
self.parser._update_defaults(self.parser.defaults)
return optparse.IndentedHelpFormatter.expand_default(self, option)
示例4: format_heading
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import IndentedHelpFormatter [as 别名]
def format_heading(self, heading):
"""
This translates any heading of "options" or "Options" into
"SCons Options." Unfortunately, we have to do this here,
because those titles are hard-coded in the optparse calls.
"""
if heading == 'Options':
heading = "SCons Options"
return optparse.IndentedHelpFormatter.format_heading(self, heading)
示例5: format_heading
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import IndentedHelpFormatter [as 别名]
def format_heading(self, heading):
"""
This translates any heading of "options" or "Options" into
"SCons Options." Unfortunately, we have to do this here,
because those titles are hard-coded in the optparse calls.
"""
if heading == 'options':
# The versions of optparse.py shipped with Pythons 2.3 and
# 2.4 pass this in uncapitalized; override that so we get
# consistent output on all versions.
heading = "Options"
if heading == 'Options':
heading = "SCons Options"
return optparse.IndentedHelpFormatter.format_heading(self, heading)
示例6: expand_default
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import IndentedHelpFormatter [as 别名]
def expand_default(self, option):
if self.parser is not None:
self.parser.update_defaults(self.parser.defaults)
return optparse.IndentedHelpFormatter.expand_default(self, option)
示例7: __init__
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import IndentedHelpFormatter [as 别名]
def __init__(self, banner, *argv, **argd):
self.banner = banner
optparse.IndentedHelpFormatter.__init__(self, *argv, **argd)
示例8: format_usage
# 需要导入模块: import optparse [as 别名]
# 或者: from optparse import IndentedHelpFormatter [as 别名]
def format_usage(self, usage):
msg = optparse.IndentedHelpFormatter.format_usage(self, usage)
return '%s\n%s' % (self.banner, msg)
# See Process.generate_memory_snapshot()