Coerce a value to a severity--options tuple.
517782
function coerce(name, value) {
  var def = 1
  var result
  var level

  /* istanbul ignore if - Handled by unified in v6.0.0 */
  if (typeof value === 'boolean') {
    result = [value]
  } else if (value == null) {
    result = [def]
  } else if (
    typeof value === 'object' &&
    (typeof value[0] === 'number' ||
      typeof value[0] === 'boolean' ||
      typeof value[0] === 'string')
  ) {
    result = value.concat()
  } else {
    result = [1, value]
  }

  level = result[0]

  if (typeof level === 'boolean') {
    level = level ? 1 : 0
  } else if (typeof level === 'string') {
    if (level === 'off') {
      level = 0
    } else if (level === 'on' || level === 'warn') {
      level = 1
    } else if (level === 'error') {
      level = 2
    } else {
      level = 1
      result = [level, result]
    }
  }

  if (level < 0 || level > 2) {
    throw new Error(
      'Invalid severity `' +
        level +
        '` for `' +
        name +
        '`, ' +
        'expected 0, 1, or 2'
    )
  }

  result[0] = level

  return result
}
63382
def reserved(self, value):
        """"""
        self.bytearray[self._get_slicers(2)] = bytearray(c_uint16(value or 0))
114233
def convert_arguments(value):
    """"""
    if isinstance(value, (list, tuple)):
        return [
            CommandLineBinding(**item) if isinstance(item, dict) else item
            for item in value
        ]
    return shlex.split(value)
530123
def coerce(cls, key, value):
        """"""

        if not isinstance(value, MutableDict):
            if isinstance(value, dict):
                return MutableDict(value)
            elif isinstance(value, six.string_types):
                # Assume JSON string
                if value:
                    return MutableDict(simplejson.loads(value, use_decimal=True))
                else:
                    return MutableDict()  # Empty value is an empty dict

            # this call will raise ValueError
            return Mutable.coerce(key, value)
        else:
            return value
76083
def _try_coerce_args(self, values, other):
        
        # asi8 is a view, needs copy
        values = _block_shape(values.view("i8"), ndim=self.ndim)

        if isinstance(other, ABCSeries):
            other = self._holder(other)

        if isinstance(other, bool):
            raise TypeError
        elif is_datetime64_dtype(other):
            # add the tz back
            other = self._holder(other, dtype=self.dtype)

        elif is_null_datetimelike(other):
            other = tslibs.iNaT
        elif isinstance(other, self._holder):
            if other.tz != self.values.tz:
                raise ValueError("incompatible or non tz-aware value")
            other = _block_shape(other.asi8, ndim=self.ndim)
        elif isinstance(other, (np.datetime64, datetime, date)):
            other = tslibs.Timestamp(other)
            tz = getattr(other, 'tz', None)

            # test we can have an equal time zone
            if tz is None or str(tz) != str(self.values.tz):
                raise ValueError("incompatible or non tz-aware value")
            other = other.value
        else:
            raise TypeError(other)

        return values, other
727710
def coerce(cls, key, value):
        ""

        if not isinstance(value, MutableDict):
            if isinstance(value, dict):
                return MutableDict(value)

            # this call will raise ValueError
            return Mutable.coerce(key, value)
        else:
            return value
568567
def coerce(cls, key, value):
        """"""
        self = MutationList((MutationObj.coerce(key, v) for v in value))
        self._key = key
        return self
383283
def normalize_value(val):
    
    
    if val is not None:
        if val.lower() == 'false':
            val = False
        elif val.lower() == 'true':
            val = True
    
    return val
11438
def str2tuple(str_in):
    '''
    
    '''
    tuple_out = safe_eval(str_in)
    if not isinstance(tuple_out, tuple):
        tuple_out = None
    return tuple_out
236783
def cull(data,index,min=None,max=None):    
    """"""

    ret = data

    if min is not None:
        ret = ret[ret[:,index] > min,:]

    if max is not None:
        ret = ret[ret[:,index] < max,:]
    
    return ret
257035
def parse_val(cfg,section,option):
    """"""
    vals = parse_vals(cfg,section,option)
    if len(vals)==0:
        return ''
    else:
        assert len(vals)==1, (section, option, vals, type(vals))
    return vals[0]
1125086
def eval_option_value(self, option):
        
        try:
            value = eval(option, {}, {})
        except (SyntaxError, NameError, TypeError):
            return option
        if type(value) in (str, bool, int, float):
            return value
        elif type(value) in (list, tuple):
            for v in value:
                if type(v) not in (str, bool, int, float):
                    self._write_error("Value of element of list object has wrong type %s" % v)
            return value
        return option
529762
def int_option(string, options):
    
    i = int(string)
    if i in options:
        return i

    raise ValueError('Not in allowed options')
749494
def coerceType(self, ftype, value):
        
        if value is None:
            return None
        if ftype == 'string':
            return str(value)
        elif ftype == 'text':
            return str(value)
        elif ftype == 'int':
            try:
                v = int(value)
                return str(v)
            except Exception:
                return None
        elif ftype == 'float':
            try:
                v = float(value)
                return str(v)
            except Exception:
                return None
        elif ftype == 'date':
            try:
                v = datetime.datetime.strptime(value, '%b %d %Y %I:%M%p')
                return v.isoformat()
            except Exception:
                return None
        return str(value)
410138
def valuewrapper(f, arguments=None):
    
    def wrapper(**kwds):
        value = kwds.pop('value')
        return f(value, **kwds)

    if arguments is None:
        wrapper.__dict__.update(f.__dict__)
    else:
        wrapper.__dict__.update(arguments)

    return wrapper
671548
def checkValue(self,value,strict=0):
        
        v = self._coerceValue(value,strict)
        return self.checkOneValue(v,strict)
703827
def escape_values(values):
    
    if isinstance(values, (tuple, list)):
        return tuple([escape(value) for value in values])
    elif isinstance(values, dict):
        return dict([
            (key, escape(value)) for (key, value) in values.items()
        ])
    else:
        raise InterfaceError("escape_values expects list, tuple or dict")