本文整理汇总了Python中optparse.Option.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Option.__init__方法的具体用法?Python Option.__init__怎么用?Python Option.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类optparse.Option
的用法示例。
在下文中一共展示了Option.__init__方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *opt_str, **attrs):
"""
*opt_str: Same meaning as in twitter.common.options.Option, at least one is required.
**attrs: See twitter.common.options.Option, with the following caveats:
Exactly one of the following must be provided:
clusters: A static Clusters object from which to pick clusters.
cluster_provider: A function that takes a cluster name and returns a Cluster object.
"""
self.clusters = attrs.pop('clusters', None)
self.cluster_provider = attrs.pop('cluster_provider', None)
if not (self.clusters is not None) ^ (self.cluster_provider is not None):
raise ValueError('Must specify exactly one of clusters and cluster_provider.')
default_attrs = dict(
default=None,
action='store',
type='mesos_cluster',
help='Mesos cluster to use (Default: %%default)'
)
combined_attrs = default_attrs
combined_attrs.update(attrs) # Defensive copy
Option.__init__(self, *opt_str, **combined_attrs) # old-style superclass
示例2: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__( self, *args, **kwargs ):
try:
ltype = kwargs.pop('ltype')
except:
ltype = None
Option.__init__( self, *args, **kwargs )
self.ltype = ltype
示例3: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, opt, *args, **kwargs):
if 'dest' not in kwargs:
# Override default dest, which would strip first two characters:
kwargs['dest'] = opt.replace('-', '_')
self.group = kwargs['group']
del kwargs['group']
Option.__init__(self, opt, *args, **kwargs)
示例4: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *opts, **attrs):
self.subopt_map = {}
if "subopt" in attrs:
self._short_opts = []
self._long_opts = []
self._set_opt_strings(opts)
self.baseopt = self._short_opts[0] or self._long_opts[0]
opts = ()
Option.__init__(self, *opts, **attrs)
示例5: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *args, **kwargs):
if 'group' in kwargs:
self.group = kwargs['group']
del kwargs['group']
else:
self.group = None
if 'option' in kwargs:
self.option = kwargs['option']
del kwargs['option']
else:
self.option = None
if 'conflict_group' in kwargs:
self.conflict_group = kwargs['conflict_group']
del kwargs['conflict_group']
else:
self.conflict_group = None
Option.__init__(self, *args, **kwargs)
示例6: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *opts, **attrs):
if 'choices' in attrs:
attrs['choices'] = [ attr.lower() for attr in attrs['choices'] ]
CustomOption.__init__(self, *opts, **attrs)
示例7: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *opts, **attrs):
BaseOption.__init__(self, *opts, **attrs)
if hasattr(self, "hide") and self.hide:
self.help = SUPPRESS_HELP
示例8: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *args, **kwargs):
completer = kwargs.pop('completer', None)
Option.__init__(self, *args, **kwargs)
if completer:
self.completer = completer
示例9: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *args, **kwargs):
kwargs['type'] = 'float'
Option.__init__(self, *args, **kwargs) # Option is old-style class
示例10: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *opts, **attrs):
Option.__init__(self, *opts, **attrs)
示例11: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self.deprecated = False
self.required = False
Option.__init__(self, *args, **kwargs)
示例12: __init__
# 需要导入模块: from optparse import Option [as 别名]
# 或者: from optparse.Option import __init__ [as 别名]
def __init__(self, *opts, **attrs):
Option.__init__(self, *opts, **attrs)
self._look_for_config_value()
self._look_for_env_var()