本文整理汇总了Python中optparse.OptionParser.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python OptionParser.__init__方法的具体用法?Python OptionParser.__init__怎么用?Python OptionParser.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类optparse.OptionParser
的用法示例。
在下文中一共展示了OptionParser.__init__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from optparse import OptionParser [as 别名]
# 或者: from optparse.OptionParser import __init__ [as 别名]
def __init__(self, usage, default_section, config_file = None):
"""This is an option parser that reads defaults from a config file.
It also allows specification of types for each option (unlike our mess
that is mainline BitTorrent), and is only a slight extension on the
classes provided in the Python standard libraries (unlike the
wheel reinvention in mainline).
@param usage: usage string for this application.
@param default_section: section in the config file containing configuration
for this service. This is a default that can be overriden for
individual options by passing section as a kwarg to add_option.
"""
self._default_section = default_section
OptionParser.__init__(self,usage)
RawConfigParser.__init__(self)
if config_file:
self.read(config_file)
示例2: __init__
# 需要导入模块: from optparse import OptionParser [as 别名]
# 或者: from optparse.OptionParser import __init__ [as 别名]
def __init__(self, hr):
self.hr = hr
示例3: __init__
# 需要导入模块: from optparse import OptionParser [as 别名]
# 或者: from optparse.OptionParser import __init__ [as 别名]
def __init__(self, unsaved_options=None):
OptionParser.__init__(self, unsaved_options)
示例4: __init__
# 需要导入模块: from optparse import OptionParser [as 别名]
# 或者: from optparse.OptionParser import __init__ [as 别名]
def __init__(self):
OptionParser.__init__(self, version="%%prog %s" % __version__)
group = OptionGroup(self, "Network Options")
group.add_option("-H", "--host",
dest="host", default=config.get('gntp', 'hostname'),
help="Specify a hostname to which to send a remote notification. [%default]")
group.add_option("--port",
dest="port", default=config.getint('gntp', 'port'), type="int",
help="port to listen on [%default]")
group.add_option("-P", "--password",
dest='password', default=config.get('gntp', 'password'),
help="Network password")
self.add_option_group(group)
group = OptionGroup(self, "Notification Options")
group.add_option("-n", "--name",
dest="app", default='Python GNTP Test Client',
help="Set the name of the application [%default]")
group.add_option("-s", "--sticky",
dest='sticky', default=False, action="store_true",
help="Make the notification sticky [%default]")
group.add_option("--image",
dest="icon", default=None,
help="Icon for notification (URL or /path/to/file)")
group.add_option("-m", "--message",
dest="message", default=None,
help="Sets the message instead of using stdin")
group.add_option("-p", "--priority",
dest="priority", default=0, type="int",
help="-2 to 2 [%default]")
group.add_option("-d", "--identifier",
dest="identifier",
help="Identifier for coalescing")
group.add_option("-t", "--title",
dest="title", default=None,
help="Set the title of the notification [%default]")
group.add_option("-N", "--notification",
dest="name", default='Notification',
help="Set the notification name [%default]")
group.add_option("--callback",
dest="callback",
help="URL callback")
self.add_option_group(group)
# Extra Options
self.add_option('-v', '--verbose',
dest='verbose', default=0, action='count',
help="Verbosity levels")