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
0
 def __init__( self, *args, **kwargs ):
     try:
         ltype = kwargs.pop('ltype')
     except:
         ltype = None
     Option.__init__( self, *args, **kwargs )
     self.ltype = ltype
Пример #3
0
    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
Пример #4
0
    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)
Пример #5
0
    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)
Пример #6
0
    def __init__(self, *args, **kwds):
        try:
            self.config_key = kwds["config_key"]
            del kwds["config_key"]
        except KeyError:
            self.config_key = None

        Option.__init__(self, *args, **kwds)
        self._seen = False
Пример #7
0
    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)
Пример #8
0
    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)
Пример #9
0
    def __init__(self, *args, **kwargs):
        self.group_parser = kwargs['group_parser']
        del kwargs['group_parser']

        self.title = kwargs['title']
        del kwargs['title']

        if 'metavar' not in kwargs:
            kwargs['metavar'] = 'opt,opt,...'

        Option.__init__(self, *args, **kwargs)

        self._check_dest()
Пример #10
0
    def __init__(self, *args, **kwargs):
        self.group_parser = kwargs['group_parser']
        del kwargs['group_parser']

        self.title = kwargs['title']
        del kwargs['title']

        if 'metavar' not in kwargs:
            kwargs['metavar'] = 'opt,opt,...'

        Option.__init__(self, *args, **kwargs)

        self._check_dest()
Пример #11
0
    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)
 def __init__(self, *opts, **attrs):
     BaseOption.__init__(self, *opts, **attrs)
     if hasattr(self, "hide") and self.hide:
         self.help = SUPPRESS_HELP
 def __init__(self, *opts, **attrs):
     Option.__init__(self, *opts, **attrs)
     self._look_for_config_value()
     self._look_for_env_var()
Пример #14
0
 def __init__(self, *args, **kwargs):
     completer = kwargs.pop('completer', None)
     Option.__init__(self, *args, **kwargs)
     if completer:
         self.completer = completer
Пример #15
0
 def __init__(self, *opts: str, **attrs: Any) -> None:
     BaseOption.__init__(self, *opts, **attrs)
     # mypy: "Option" has no attribute "hide"
     # we test that in the if
     if hasattr(self, "hide") and self.hide:  # type: ignore
         self.help = SUPPRESS_HELP
Пример #16
0
 def __init__(self, *opts, **attrs):
     BaseOption.__init__(self, *opts, **attrs)
     if hasattr(self, "hide") and self.hide:
         self.help = SUPPRESS_HELP
Пример #17
0
 def __init__(self, *args, **kwargs):
     kwargs['type'] = 'float'
     Option.__init__(self, *args, **kwargs)  # Option is old-style class
Пример #18
0
 def __init__(self, *opts, **attrs):
     if 'choices' in attrs:
         attrs['choices'] = [attr.lower() for attr in attrs['choices']]
     CustomOption.__init__(self, *opts, **attrs)
Пример #19
0
 def __init__(self, *opts, **attrs):
     Option.__init__(self, *opts, **attrs)
Пример #20
0
 def __init__(self, *args, **kwargs):
     self.deprecated = False
     self.required = False
     Option.__init__(self, *args, **kwargs)
Пример #21
0
 def __init__(self, *args, **kwargs):
     self.deprecated = False
     self.required = False
     Option.__init__(self, *args, **kwargs)
Пример #22
0
 def __init__(self, *args, **kwargs):
     completer = kwargs.pop('completer', None)
     Option.__init__(self, *args, **kwargs)
     if completer:
         self.completer = completer
Пример #23
0
 def __init__(self, *opts, **attrs):
     if 'choices' in attrs:
         attrs['choices'] = [ attr.lower() for attr in attrs['choices'] ]
     CustomOption.__init__(self, *opts, **attrs)
Пример #24
0
 def __init__(self, *opts, **attrs):
     Option.__init__(self, *opts, **attrs)