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