When reading an attribute, we need to handle reading on:
 1) a nil model, which returns a wrapped error
 2) reading directly from attributes
 3) trying to read a key that doesn't exist.
494317
def get(attr_name, expand = false)
      # Reading an attribute, we may get back a nil model.
      attr_name = attr_name.to_sym

      check_valid_field_name(attr_name)

      # Track that something is listening
      @root_dep.depend

      # Track dependency
      @deps.depend(attr_name)

      # See if the value is in attributes
      if @attributes && @attributes.key?(attr_name)
        return @attributes[attr_name]
      else
        # If we're expanding, or the get is for a collection, in which
        # case we always expand.
        plural_attr = attr_name.plural?
        if expand || plural_attr
          new_value = read_new_model(attr_name)

          # A value was generated, store it
          if new_value
            # Assign directly.  Since this is the first time
            # we're loading, we can just assign.
            #
            # Don't track changes if we're setting a collection
            Volt.run_in_mode_if(plural_attr, :no_change_tracking) do
              set(attr_name, new_value)
            end
          end

          return new_value
        else
          return nil
        end
      end
    end
464826
def get_attribute(instance, attrs):
    
    for attr in attrs:
        if instance is None:
            # Break out early if we get `None` at any point in a nested lookup.
            return None
        try:
            if isinstance(instance, collections.Mapping):
                instance = instance[attr]
            else:
                instance = getattr(instance, attr)
        except ObjectDoesNotExist:
            return None
        if is_simple_callable(instance):
            try:
                instance = instance()
            except (AttributeError, KeyError) as exc:
                # If we raised an Attribute or KeyError here it'd get treated
                # as an omitted field in `Field.get_attribute()`. Instead we
                # raise a ValueError to ensure the exception is not masked.
                raise ValueError('Exception raised in callable attribute "{0}"; original exception was: {1}'.format(attr, exc))

    return instance
272879
def validate_read(self, kwargs):
        
        kwargs = super().validate_read(kwargs)
        if 'start' in kwargs or 'stop' in kwargs:
            raise NotImplementedError("start and/or stop are not supported "
                                      "in fixed Sparse reading")
        return kwargs
733280
def read_attribute(name, options = {})
      options = {:translated => true, :locale => nil}.merge(options)
      if translated?(name) and options[:translated]
        globalize.fetch(options[:locale] || Mongoid::Globalize.locale, name)
      else
        super(name)
      end
    end
28419
function handleSimpleAttribute() {
    SIMPLEATTR.lastIndex = nextchar-1;
    var matched = SIMPLEATTR.exec(chars);
    if (!matched) throw new Error("should never happen");
    var name = matched[1];
    if (!name) return false;
    var value = matched[2];
    var len = value.length;
    switch(value[0]) {
    case '"':
    case "'":
      value = value.substring(1, len-1);
      nextchar += (matched[0].length-1);
      tokenizer = after_attribute_value_quoted_state;
      break;
    default:
      tokenizer = before_attribute_name_state;
      nextchar += (matched[0].length-1);
      value = value.substring(0, len-1);
      break;
    }

    // Make sure there isn't already an attribute with this name
    // If there is, ignore this one.
    for(var i = 0; i < attributes.length; i++) {
      if (attributes[i][0] === name) return true;
    }

    attributes.push([name, value]);
    return true;
  }
57992
def inspect
      attrs = []
      attrs << ['key', @key.inspect] unless @key.nil?
      attrs << ['value', @value.inspect] unless @value.nil?
      model.attributes.map do |attr, default|
        val = read_attribute(attr)
        attrs << [attr.to_s, val.inspect] unless val.nil?
      end
      attrs.sort!
      attrs.unshift([:id, id]) unless new?
      sprintf('#<%s %s>', model, attrs.map { |a| a.join(': ') }.join(', '))
    end
250869
def read_body
      body = @attributes['body']
      if body.nil?
        ''
      elsif body.is_a?(String)
        body
      elsif body.respond_to?(:read) && body.respond_to?(:rewind)
        body.rewind
        body.read.tap do
          body.rewind
        end
      else
        raise TypeError, "Body must be a String or something IO-like (responding to #read and #rewind). " +
          "got body = #{body.inspect}"
      end
    end
753480
def read(value = nil)
      clone.tap do |criteria|
        criteria.options.merge!(read: value)
      end
    end
858211
function _decodeBagAttributes(attributes) {
  var decodedAttrs = {};

  if(attributes !== undefined) {
    for(var i = 0; i < attributes.length; ++i) {
      var capture = {};
      var errors = [];
      if(!asn1.validate(attributes[i], attributeValidator, capture, errors)) {
        var error = new Error('Cannot read PKCS#12 BagAttribute.');
        error.errors = errors;
        throw error;
      }

      var oid = asn1.derToOid(capture.oid);
      if(pki.oids[oid] === undefined) {
        // unsupported attribute type, ignore.
        continue;
      }

      decodedAttrs[pki.oids[oid]] = [];
      for(var j = 0; j < capture.values.length; ++j) {
        decodedAttrs[pki.oids[oid]].push(capture.values[j].value);
      }
    }
  }

  return decodedAttrs;
}
105694
def is_attribute?
      info = attr_info
      if info
        read_or_write = name.to_s =~ /=$/ ? :write : :read
        info[read_or_write] ? true : false
      else
        false
      end
    end
951992
def read(hash)
      self.scale = hash.delete('scale').sub(/x$/, '').to_i unless hash['scale'].nil?

      KNOWN_KEYS.each do |key|
        value = hash.delete(key.to_s.dasherize)
        next if value.nil?
        self.send "#{key}=".to_sym, value
      end

      self.attributes = hash

      return self
    end
960580
private void handleKeysAttr(final Attributes atts) {
        final String attrValue = atts.getValue(ATTRIBUTE_NAME_KEYS);
        if (attrValue != null) {
            URI target = toURI(atts.getValue(ATTRIBUTE_NAME_HREF));
            final URI copyTo = toURI(atts.getValue(ATTRIBUTE_NAME_COPY_TO));
            if (copyTo != null) {
                target = copyTo;
            }

            final String keyRef = atts.getValue(ATTRIBUTE_NAME_KEYREF);

            // Many keys can be defined in a single definition, like
            // keys="a b c", a, b and c are seperated by blank.
            for (final String key : attrValue.trim().split("\\s+")) {
                if (!keysDefMap.containsKey(key)) {
                    if (target != null && !target.toString().isEmpty()) {
                        final String attrScope = atts.getValue(ATTRIBUTE_NAME_SCOPE);
                        final String attrFormat = atts.getValue(ATTRIBUTE_NAME_FORMAT);
                        if (attrScope != null && (attrScope.equals(ATTR_SCOPE_VALUE_EXTERNAL) || attrScope.equals(ATTR_SCOPE_VALUE_PEER))) {
                            keysDefMap.put(key, new KeyDef(key, target, attrScope,  attrFormat, null, null));
                        } else {
                            String tail = null;
                            if (target.getFragment() != null) {
                                tail = target.getFragment();
                                target = stripFragment(target);
                            }
                            if (!target.isAbsolute()) {
                                target = currentDir.resolve(target);
                            }
                            keysDefMap.put(key, new KeyDef(key, setFragment(target, tail), ATTR_SCOPE_VALUE_LOCAL, attrFormat, null, null));
                        }
                    } else if (!StringUtils.isEmptyString(keyRef)) {
                        // store multi-level keys.
                        keysRefMap.put(key, keyRef);
                    } else {
                        // target is null or empty, it is useful in the future
                        // when consider the content of key definition
                        keysDefMap.put(key, new KeyDef(key, null, null, null, null, null));
                    }
                } else {
                    logger.info(MessageUtils.getMessage("DOTJ045I", key).toString());
                }
            }
        }
    }
1250438
def on_attribute(self, node):    # ('value', 'attr', 'ctx')
        """"""
        ctx = node.ctx.__class__
        if ctx == ast.Store:
            msg = "attribute for storage: shouldn't be here!"
            self.raise_exception(node, exc=RuntimeError, msg=msg)

        sym = self.run(node.value)
        if ctx == ast.Del:
            return delattr(sym, node.attr)

        # ctx is ast.Load
        fmt = "cannnot access attribute '%s' for %s"
        if node.attr not in UNSAFE_ATTRS:
            fmt = "no attribute '%s' for %s"
            try:
                return getattr(sym, node.attr)
            except AttributeError:
                pass

        # AttributeError or accessed unsafe attribute
        obj = self.run(node.value)
        msg = fmt % (node.attr, obj)
        self.raise_exception(node, exc=AttributeError, msg=msg)
397251
def getattr(self, obj, attribute):
        
        try:
            return getattr(obj, attribute)
        except AttributeError:
            pass
        try:
            return obj[attribute]
        except (TypeError, LookupError, AttributeError):
            return self.undefined(obj=obj, name=attribute)
578506
function(inst) {
                // `can.__reading` makes a note that `id` was just read.
                can.__reading(inst, inst.constructor.id);
                // Use `__get` instead of `attr` for performance. (But that means we have to remember to call `can.__reading`.)
                return inst.__get(inst.constructor.id);
            }
797749
def read_mda(attribute):
        """"""
        lines = attribute.split('\n')
        mda = {}
        current_dict = mda
        path = []
        prev_line = None
        for line in lines:
            if not line:
                continue
            if line == 'END':
                break
            if prev_line:
                line = prev_line + line
            key, val = line.split('=')
            key = key.strip()
            val = val.strip()
            try:
                val = eval(val)
            except NameError:
                pass
            except SyntaxError:
                prev_line = line
                continue
            prev_line = None
            if key in ['GROUP', 'OBJECT']:
                new_dict = {}
                path.append(val)
                current_dict[val] = new_dict
                current_dict = new_dict
            elif key in ['END_GROUP', 'END_OBJECT']:
                if val != path[-1]:
                    raise SyntaxError
                path = path[:-1]
                current_dict = mda
                for item in path:
                    current_dict = current_dict[item]
            elif key in ['CLASS', 'NUM_VAL']:
                pass
            else:
                current_dict[key] = val
        return mda
1334738
function(attr) {
                    var value;
                    // Handles the case of a key having a `.` in its name
                    if (typeof attr === 'string' && !! ~attr.indexOf('.')) {
                        // Attempt to get the value
                        value = this.__get(attr);
                        // For keys with a `.` in them, value will be defined
                        if (value !== undefined) {
                            return value;
                        }
                    }

                    // Otherwise we have to dig deeper into the Map to get the value.
                    // First, break up the attr (`"foo.bar"`) into parts like `["foo","bar"]`.
                    var parts = can.Map.helpers.attrParts(attr),
                        // Then get the value of the first attr name (`"foo"`).
                        current = this.__get(parts.shift());
                    // If there are other attributes to read...
                    return parts.length ?
                    // and current has a value...
                    current ?
                    // then lookup the remaining attrs on current
                    current._get(parts) :
                    // or if there's no current, return undefined.
                    undefined :
                    // If there are no more parts, return current.
                    current;
                }