本文整理匯總了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()