Return the value for option or default if defined.
10774
def getenv(option, default=undefined, cast=undefined):
    

    # We can't avoid __contains__ because value may be empty.
    if option in os.environ:
        value = os.environ[option]
    else:
        if isinstance(default, Undefined):
            raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))

        value = default

    if isinstance(cast, Undefined):
        return value

    if cast is bool:
        value = _cast_boolean(value)
    elif cast is list:
        value = [x for x in value.split(',') if x]
    else:
        value = cast(value)

    return value
347956
def get_option_int(self, name, section=None, vars=None, expect=None):
        """"""
        val = self.get_option(name, section, vars, expect)
        if val:
            return int(val)
467653
def value(self):
    
    if self.is_multi_select():
      return [opt.value()
              for opt in self.xpath(".//option")
              if opt["selected"]]
    else:
      return self._invoke("value")
853092
def get_default_for(prop, value):
    

    prop = prop.strip('_')     # Handle alternate props (leading underscores)
    val = reduce_value(value)  # Filtering of value happens here

    if prop in _COMPLEX_LISTS:
        return wrap_value(val)
    elif prop in _COMPLEX_STRUCTS:
        return val or {}
    else:
        return u'' if val is None else val
736184
def resolve_return_value_options(self, options):
        """"""
        for key, value in options.items():
            if isinstance(value, str) and value.startswith(RETURN_VALUE_OPTION_PREFIX):
                path, name = value[len(RETURN_VALUE_OPTION_PREFIX) :].rsplit(".", 1)
                result = self._find_result_by_path(path)
                options[key] = result.return_values.get(name)
952699
def _GetValue(self, name, context, default=utils.NotAValue):
    """"""
    container = self.defaults

    # The caller provided a default value.
    if default is not utils.NotAValue:
      value = default

    # Take the default from the definition.
    elif name in self.defaults:
      value = self.defaults[name]

    else:
      raise UnknownOption("Option %s not defined." % name)

    # We resolve the required key with the default raw data, and then iterate
    # over all elements in the context to see if there are overriding context
    # configurations.
    new_value = self.raw_data.get(name)
    if new_value is not None:
      value = new_value
      container = self.raw_data

    # Now check for any contexts. We enumerate all the possible resolutions and
    # sort by their path length. The last one will be the match with the deepest
    # path (i.e .the most specific match).
    matches = list(self._ResolveContext(context, name, self.raw_data))

    if matches:
      # Sort by the length of the path - longest match path will be at the end.
      matches.sort(key=lambda x: len(x[2]))
      value = matches[-1][1]
      container = matches[-1][0]

      if (len(matches) >= 2 and len(matches[-1][2]) == len(matches[-2][2]) and
          matches[-1][2] != matches[-2][2] and
          matches[-1][1] != matches[-2][1]):
        # This warning specifies that there is an ambiguous match, the config
        # attempts to find the most specific value e.g. if you have a value
        # for X.y in context A,B,C, and a value for X.y in D,B it should choose
        # the one in A,B,C. This warning is for if you have a value in context
        # A,B and one in A,C. The config doesn't know which one to pick so picks
        # one and displays this warning.
        logging.warning(
            "Ambiguous configuration for key %s: "
            "Contexts of equal length: %s (%s) and %s (%s)", name,
            matches[-1][2], matches[-1][1], matches[-2][2], matches[-2][1])

    # If there is a writeback location this overrides any previous
    # values.
    if self.writeback_data:
      new_value = self.writeback_data.get(name)
      if new_value is not None:
        value = new_value
        container = self.writeback_data

    # Allow the global override to force an option value.
    if name in self.global_override:
      return self.global_override, self.global_override[name]

    return container, value
573707
def get_default_value(self):
        
        default = self.default_value
        if isinstance(default, collections.Callable):
            default = default()
        return default
434708
def _check_default(value, parameter, default_chars):
    ''''''
    # not using a set here because it fails when value is unhashable
    if value in default_chars:
        if parameter.default is inspect.Parameter.empty:
            raise ValueError('Value was empty, but no default value is given in view function for parameter: {} ({})'.format(parameter.position, parameter.name))
        return parameter.default
    return value
205032
def default(self):
        
        if isinstance(self.__default, (str, unicode)):
            return self.valueFromString(self.__default)
        else:
            return self.__default
296955
def get(key, default=-1):
        """"""
        if isinstance(key, int):
            return Option(key)
        if key not in Option._member_map_:
            extend_enum(Option, key, default)
        return Option[key]
258092
def has_option(self, section, option):
        """"""
        if not section or section == self.default_section:
            option = self.optionxform(option)
            return option in self._defaults
        elif section not in self._sections:
            return False
        else:
            option = self.optionxform(option)
            return (option in self._sections[section]
                    or option in self._defaults)
1222603
def _option(value):
    '''
    
    '''
    if value in __opts__:
        return __opts__[value]
    master_opts = __pillar__.get('master', {})
    if value in master_opts:
        return master_opts[value]
    if value in __pillar__:
        return __pillar__[value]
660208
def getopt(self, p, default=None):
        """"""
        for k, v in self.pairs:
            if k == p:
                return v
        return default
847532
function defaults(options, defaultOption) {
  options = options || {};
  for (var i in defaultOption) {
    if (own(defaultOption, i) && !(i in options)) options[i] = defaultOption[i];
  }
  return options
}
1233584
def Default(default):
    
    @wraps(Default)
    def built(value):
        if value == None:
            return default
        return value
    return built
921522
def get_value(self, index=None):
        

        if self.value is None:
            return self.default
        if index is not None:
            if self.value[index] is None:
                return self.default
            else:
                value = self.value[index]
        else:
            value = self.value

        return value
651915
def get_default(parser, section, option, default):
    """"""
    try:
        result = parser.get(section, option)
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
        result = default
    return result