在当前对象此字段上赋值

        :param key_or_attrs: 字段名，或者一个包含 字段名 / 值的 dict
        :type key_or_attrs: string_types or dict
        :param value: 字段值
        :param unset:
        :return: 当前对象，供链式调用
434607
def set(self, key_or_attrs, value=None, unset=False):
        
        if isinstance(key_or_attrs, dict) and value is None:
            attrs = key_or_attrs
            keys = attrs.keys()
            for k in keys:
                if isinstance(attrs[k], LocalProxy):
                    attrs[k] = attrs[k]._get_current_object()
        else:
            key = key_or_attrs
            if isinstance(value, LocalProxy):
                value = value._get_current_object()
            attrs = {key: utils.decode(key, value)}

        if unset:
            for k in attrs.keys():
                attrs[k] = operation.Unset()

        self.validate(attrs)

        self._merge_metadata(attrs)

        keys = list(attrs.keys())
        for k in keys:
            v = attrs[k]
            # TODO: Relation

            if not isinstance(v, operation.BaseOp):
                v = operation.Set(v)

            self._attributes[k] = v._apply(self._attributes.get(k), self, k)
            if self._attributes[k] == operation._UNSET:
                del self._attributes[k]
            self._changes[k] = v._merge(self._changes.get(k))

        return self
1254137
def value_getattr():
    

    def value_getattr(value, context, **_params):
        value = getattr(value, context["key"])
        return _attr(value)

    return source_getattr
1038686
def code(self, value):
        
        if value not in list(defines.Codes.LIST.keys()) and value is not None:
            raise AttributeError
        self._code = value
1135071
def from_dict(self, value):
        
        for key in self.keys():
            setattr(self, key, value.get(key, None))
1310921
def _set_attrs(self, attrs, allow_ro=False, from_json=True):
    
    for k, v in attrs.iteritems():
      attr = self._check_attr(k, allow_ro)
      if attr and from_json:
        v = attr.from_json(self._get_resource_root(), v)
      object.__setattr__(self, k, v)
1012397
function(attrs, options) {

        var attr, key, eve;
        if (attrs === null) return this;

        if (attrs.eClass) {
            attrs = attrs.get('name');
        }

        // Handle attrs is a hash or attrs is
        // property and options the value to be set.
        if (!_.isObject(attrs)) {
            key = attrs;
            (attrs = {})[key] = undefined;
        }

        var eResource = this.eResource();

        for (attr in attrs) {
            if (this.has(attr) && this.isSet(attr)) {
              // unset

              var feature = getEStructuralFeature(this.eClass, attr),
                  isContainment = Boolean(feature.get('containment')) === true;
              var value = this.values[attr];

                if (isContainment) {
                  value.eContainingFeature = undefined;
                  value.eContainer = undefined;
                }
              this.values[attr] = undefined;
              eve = 'unset:' + attr;
              this.trigger('unset ' + eve, attr);
              if (eResource) eResource.trigger('change', this);
            }
        }

        return this;
    }
42353
def attribute(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "attribute", value)
        self.__attribute = value
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());
                }
            }
        }
    }
1073240
def _reset_attr(self, name, func=None, doc=None, preload=False):
        ""

        keys = set(self)
        if name not in keys:
            try:
                data, funcs = zip(*[
                    (
                        (
                            key, (
                                getattr(self._attr_data_, key)
                                if hasattr(self._attr_data_, key)
                                else None
                            )
                        ),
                        (
                            key, (
                                getattr(self._attr_func_, key)
                                if hasattr(self._attr_func_, key)
                                else None
                            )
                        ),
                    )
                    for key in keys
                ])

                keys.add(name)
                self._attr_data_ = keys
                self._attr_func_ = keys

                [
                    setattr(self._attr_data_, key,  value)
                    for key, value in data
                    if value is not None
                ]
                [
                    setattr(self._attr_func_, key,  value)
                    for key, value in funcs
                    if value is not None
                ]

            except ValueError:
                keys.add(name)
                self._attr_data_ = keys
                self._attr_func_ = keys

        if hasattr(self._attr_data_, name):
            delattr(self._attr_data_, name)

        if func is not None:
            setattr(self._attr_func_, name, func)

        elif hasattr(self._attr_func_, name):
            delattr(self._attr_func_, name)

        self._set_attr(name, doc, preload)
459624
def _index_key_for(self, att, value=None):
        
        if value is None:
            value = getattr(self, att)
            if callable(value):
                value = value()
        if value is None:
            return None
        if att not in self.lists:
            return self._get_index_key_for_non_list_attr(att, value)
        else:
            return self._tuple_for_index_key_attr_list(att, value)
336202
function(options) {
          var attrs = {};
          for (var key in this.attributes) attrs[key] = void 0;
          return this.set(attrs, mixin({}, options, {unset: true}));
        }
190900
def detach_attrs_factory(f):
    """"""

    # Get the name and standard length
    name = f.__closure__[0].cell_contents
    n = f.__closure__[1].cell_contents

    def detach_attrs(key, value, fmt, meta):  # pylint: disable=unused-argument
        """Detaches the attributes."""
        if key == name:
            assert len(value) <= n+1
            if len(value) == n+1:
                # Make sure value[0] represents attributes then delete
                assert len(value[0]) == 3
                assert isinstance(value[0][0], STRTYPES)
                assert isinstance(value[0][1], list)
                assert isinstance(value[0][2], list)
                del value[0]

    return detach_attrs
243291
def unset(self, name):
        
        try:
            attr = self.getAttribute(name)
            self.attributes.remove(attr)
        except Exception:
            pass
        return self
627885
def put_attributes(self, attrs):
        
        assert(isinstance(attrs, dict)), "Argument must be a dict of key->values to save"
        for prop_name in attrs:
            value = attrs[prop_name]
            prop = self.find_property(prop_name)
            assert(prop), "Property not found: %s" % prop_name
            self._manager.set_property(prop, self, prop_name, value)
        self.reload()
        return self
863369
def _remove_attributes(attrs, remove_list):
    
    new_attrs = {}
    for attr in attrs.keys():
        if attr not in remove_list:
            new_attrs[attr] = attrs[attr]
    return new_attrs
1145348
def set_from_dict(self, data, source=None):
        
        if source:
            self._source = source

        if not data:
            return

        for key, value in data.items():
            key = key.replace("-", "_")
            if not hasattr(self, key):
                LOG.debug("%s is not an attribute of %s", key, self.__class__.__name__)
                continue

            attr = getattr(self, key)
            if attr is not None and not same_type(value, attr):
                source = getattr(self, "_source", None)
                origin = " in %s" % source if source else ""
                LOG.debug("Wrong type '%s' for %s.%s%s, expecting '%s'", type_name(value), type_name(self), key, origin, type_name(attr))
                continue

            setattr(self, key, value)
1306827
def unwrap(self, value, session=None):
        ''' 
        '''
        self.validate_unwrap(value)
        ret = {}
        for value_dict in value:
            k = value_dict['k']
            v = value_dict['v']
            ret[self.key_type.unwrap(k, session=session)] = self.value_type.unwrap(v, session=session)
        return ret