Check that `options` has a value for `key` with type
  `_type`. Return that value. `options_name` is a string representing a
  human-readable name for `options` to be used when printing errors.
778305
def _validate_and_get_value(options, options_name, key, _type):
  
  if isinstance(options, dict):
    has = lambda k: k in options
    get = lambda k: options[k]
  elif isinstance(options, object):
    has = lambda k: hasattr(options, k)
    get = lambda k: getattr(options, k)
  else:
    raise ImproperlyConfigured(
        '`{}` must be a dictionary-like object.'.format(options_name))

  if not has(key):
    raise ImproperlyConfigured(
        '`{}` must be specified in `{}`'.format(key, options_name))

  value = get(key)
  if not isinstance(value, _type):
    raise ImproperlyConfigured(
        '`{}` in `{}` must be a {}'.format(key, options_name, repr(_type)))

  return value
1064725
def parse_name_options(name, arg_split:':', **keywords)
			name,*options=name.split(arg_split)
			return name, parse_options(options, arg_split: arg_split, **keywords)
		end
1294084
def is_valid_variable_name(string_to_check):
    

    try:

        parse('{} = None'.format(string_to_check))
        return True

    except (SyntaxError, ValueError, TypeError):

        return False
626418
def getOption(self, name):
    
    name = name.strip()
    for o in self.options:
      if o.short == name or o.long == name:
        return o
    raise InterfaceException("No such option: " + name)
1124490
def has_option(self, option_name=None):
		
		if option_name is None:
			option_name = ''
		return self.config().has_option(self.section(), self.option_prefix() + option_name)
176643
def check_option(name)
      value = instance_variable_get('@' + name)

      if @config.include?(name)
        # The database already existed and has a setting for this config
        # option. If it does not match the instance variable, adjust the
        # instance variable accordingly.
        unless @config[name] == value
          instance_variable_set('@' + name, @config[name])
        end
      else
        # There is no such config option yet. Create it with the value of the
        # corresponding instance variable.
        @config[name] = value
      end
    end
581152
def _validate_opts(opts):
    '''
    
    '''
    def format_multi_opt(valid_type):
        try:
            num_types = len(valid_type)
        except TypeError:
            # Bare type name won't have a length, return the name of the type
            # passed.
            return valid_type.__name__
        else:
            def get_types(types, type_tuple):
                for item in type_tuple:
                    if isinstance(item, tuple):
                        get_types(types, item)
                    else:
                        try:
                            types.append(item.__name__)
                        except AttributeError:
                            log.warning(
                                'Unable to interpret type %s while validating '
                                'configuration', item
                            )
            types = []
            get_types(types, valid_type)

            ret = ', '.join(types[:-1])
            ret += ' or ' + types[-1]
            return ret

    errors = []

    err = (
        'Config option \'{0}\' with value {1} has an invalid type of {2}, a '
        '{3} is required for this option'
    )
    for key, val in six.iteritems(opts):
        if key in VALID_OPTS:
            if val is None:
                if VALID_OPTS[key] is None:
                    continue
                else:
                    try:
                        if None in VALID_OPTS[key]:
                            continue
                    except TypeError:
                        # VALID_OPTS[key] is not iterable and not None
                        pass

            if isinstance(val, VALID_OPTS[key]):
                continue

            # We don't know what data type sdb will return at run-time so we
            # simply cannot check it for correctness here at start-time.
            if isinstance(val, six.string_types) and val.startswith('sdb://'):
                continue

            if hasattr(VALID_OPTS[key], '__call__'):
                try:
                    VALID_OPTS[key](val)
                    if isinstance(val, (list, dict)):
                        # We'll only get here if VALID_OPTS[key] is str or
                        # bool, and the passed value is a list/dict. Attempting
                        # to run int() or float() on a list/dict will raise an
                        # exception, but running str() or bool() on it will
                        # pass despite not being the correct type.
                        errors.append(
                            err.format(
                                key,
                                val,
                                type(val).__name__,
                                VALID_OPTS[key].__name__
                            )
                        )
                except (TypeError, ValueError):
                    errors.append(
                        err.format(key,
                                   val,
                                   type(val).__name__,
                                   VALID_OPTS[key].__name__)
                    )
                continue

            errors.append(
                err.format(key,
                           val,
                           type(val).__name__,
                           format_multi_opt(VALID_OPTS[key]))
            )

    # Convert list to comma-delimited string for 'return' config option
    if isinstance(opts.get('return'), list):
        opts['return'] = ','.join(opts['return'])

    for error in errors:
        log.warning(error)
    if errors:
        return False
    return True
131668
def validate_options(subscription_key, text):
    
    if not subscription_key or len(subscription_key) == 0:
        print 'Error: Warning the option subscription_key should contain a string.'
        print USAGE
        sys.exit(3)
    if not text or len(text) == 0:
        print 'Error: Warning the option text should contain a string.'
        print USAGE
        sys.exit(3)
331151
def has_value_of_type(self, var_type):
        
        if self.has_value() and self.has_type(var_type):
            return True
        return False
299206
def get_option_boolean(self, name, section=None, vars=None, expect=None):
        
        val = self.get_option(name, section, vars, expect)
        val = val.lower() if val else 'false'
        return val == 'true'
1069891
function expectKey(options, key, type) {
  if (key in options) {
    if (typeof options[key] === type) {
      return true
    }
    // eslint-disable-next-line no-console
    console.warn(`Ignoring options key '${key}' - ` +
      `expected type '${type}', received '${typeof options[key]}'`)
  }
  return false
}
1309789
def nameValue(name, value, valueType=str, quotes=False):
    
    if valueType == bool:
        if value:
            return "--%s" % name
        return ""
    if value is None:
        return ""
    if quotes:
        return "--%s '%s'" % (name, valueType(value))
    return "--%s %s" % (name, valueType(value))
1158631
def set_indexed_name(options)
      @indexed_name =
        if options[:as]
          options.delete(:as).to_s
        else
          name = options[:prefix] ? @name.to_s.sub(/^#{options[:prefix]}_/, '') : @name
          "#{@type.indexed_name(name)}#{'m' if multiple? }#{'s' if @stored}#{'v' if more_like_this?}"
        end
    end
1258390
def validate_options(self, k, v):
        """"""

        super().validate_options(k, v)
        if k == 'delimiters':
            for d in v:
                if not isinstance(d, (dict, OrderedDict)):
                    raise ValueError("{}: 'delimters' entries must be of dict type.".format(self.__class__.__name__))
                for key, value in d.items():
                    if key not in ('open', 'close', 'content'):
                        raise KeyError(
                            "{}: '{}' is not a valid key for a 'delimeters' entry.".format(self.__class__.__name__, key)
                        )
                    if not isinstance(value, str):
                        raise ValueError(
                            "{}: 'delimeters' '{}' key should have str values.".format(self.__class__.__name__, value)
                        )
210294
def get_type_name(type_name, sub_type=None):
    
    if type_name == "enum":
        return type_name
    elif type_name == "boolean":
        return "bool"
    elif type_name == "integer":
        return "long"
    elif type_name == "time":
        return "long"
    elif type_name == "object":
        return "Object"
    elif type_name == "list":
        return "List"
    elif type_name == "float":
        return "float"
    else:
        return "String"
242404
def validate_string(option, value):
    
    if isinstance(value, string_type):
        return value
    raise TypeError("Wrong type for %s, value must be "
                    "an instance of %s" % (option, string_type.__name__))
257751
def get_options_for_id(options: Dict[str, Dict[str, Any]], identifier: str):
    
    check_var(options, var_types=dict, var_name='options')
    res = options[identifier] if identifier in options.keys() else dict()
    check_var(res, var_types=dict, var_name='options[' + identifier + ']')
    return res