Parse a boolean environment variable.
973849
def parse_boolean_envvar(val):
    """"""
    if not val or val.lower() in {'false', '0'}:
        return False
    elif val.lower() in {'true', '1'}:
        return True
    else:
        raise ValueError('Invalid boolean environment variable: %s' % val)
1202225
def from_env(cls):
        """"""
        token = getenv(cls.TOKEN_ENV_VAR)
        if token is None:
            msg = 'missing environment variable: {!r}'.format(cls.TOKEN_ENV_VAR)
            raise ValueError(msg)
        return cls(api_token=token)
1232687
def parse_bool(s, default=False):
    
    if s is None:
        return default
    return TRUTH.get(s.lower(), default)
153421
private Boolean _convertToBoolean(Object value)
    {
        Boolean booleanValue;
        if (value instanceof Boolean)
        {
            booleanValue = (Boolean) value;
        }
        else
        {
            booleanValue = Boolean.parseBoolean(value.toString());
        }
        return booleanValue;
    }
1114952
def get_env_variable(var_name, default=None):
    """"""
    try:
        return os.environ[var_name]
    except KeyError:
        if default is not None:
            return default
        else:
            error_msg = 'The environment variable {} was missing, abort...'\
                        .format(var_name)
            raise EnvironmentError(error_msg)
269848
def Parse(self, stat, knowledge_base):
    """"""
    value = stat.registry_data.GetValue()
    if not value:
      raise parser.ParseError("Invalid value for key %s" % stat.pathspec.path)
    value = artifact_utils.ExpandWindowsEnvironmentVariables(
        value, knowledge_base)
    if value:
      yield rdfvalue.RDFString(value)
382934
def getbool(key, default=False):
    
    value = os.getenv(key)
    if value and value.lower() in ('true', '1'):
        value = True
    elif value and value.lower() in ('false', '0'):
        value = False
    else:
        value = default
    return value
1104417
def validate_bool(b):
    """"""
    if isinstance(b, six.string_types):
        b = b.lower()
    if b in ('t', 'y', 'yes', 'on', 'true', '1', 1, True):
        return True
    elif b in ('f', 'n', 'no', 'off', 'false', '0', 0, False):
        return False
    else:
        raise ValueError('Could not convert "%s" to boolean' % b)
146048
def _parse_environment(env_str):
    '''
    
    '''
    try:
        env = salt.utils.yaml.safe_load(env_str)
    except salt.utils.yaml.YAMLError as exc:
        raise ValueError(six.text_type(exc))
    else:
        if env is None:
            env = {}
        elif not isinstance(env, dict):
            raise ValueError(
                'The environment is not a valid YAML mapping data type.'
            )

    for param in env:
        if param not in SECTIONS:
            raise ValueError('environment has wrong section "{0}"'.format(param))

    return env
954494
static function toBoolean ($v)
  {
    return is_string ($v) ? get (self::$BOOLEAN_VALUES, $v, false) : boolval ($v);
  }
1279990
public static Boolean getEnvironmentBoolean(String name, Boolean defaultValue) {
        if (envVars == null) {
            throw new IllegalStateException("The environment vars must be provided before calling getEnvironmentBoolean.");
        }

        String value = getEnvironmentString(name, null);

        if (value == null) {
            return defaultValue;
        }
        else {
            return BOOLEAN_PATTERN.matcher(value).matches();
        }
    }
1150606
public static Boolean parseBoolean(Integer param) {
		if (param == null) return null;
		if (param == 0) return false;
		return true;
	}
1329357
def _parse_boolean(element_text, state):
    """"""
    value = None

    lowered_text = element_text.lower()
    if lowered_text == 'true':
        value = True
    elif lowered_text == 'false':
        value = False
    else:
        state.raise_error(InvalidPrimitiveValue, 'Invalid boolean value "{}"'.format(element_text))

    return value
1317692
def parse_value(val, parsebool=False):
    
    try:
        return int(val)
    except ValueError:
        pass
    try:
        return float(val)
    except:
        pass
    if parsebool:
        if re.match('yes|on', str(val), re.IGNORECASE):
            return True
        elif re.match('no|off', str(val), re.IGNORECASE):
            return False
    return val
955910
def _replace_envvar(s, _):
    """"""
    e = s.split(":")
    if len(e) > 3 or len(e) == 1 or e[0] != "env":
        raise ValueError()
    elif len(e) == 2:
        # Note: this can/should raise a KeyError (according to spec).
        return os.environ[e[1]]
    else:  # len(e) == 3
        return os.environ.get(e[1], e[2])
153543
def read_boolean_option(self, section, option):
        """"""
        if self.has_option(section, option):
            self.config[option] = self.getboolean(section, option)
27878
def parse_bool(name, value)
      if ['1', 'true', 'enabled'].include?(value.downcase)
        true
      elsif ['0', 'false'].include?(value.downcase)
        false
      else
        raise ArgumentError.new("#{value} is not a valid boolean for #{name.to_s.upcase}")
      end
    end