The default way of unstructuring ``attrs`` classes.
6307
def unstruct_strat(self):
        # type: () -> UnstructureStrategy
        """"""
        return (
            UnstructureStrategy.AS_DICT
            if self._unstructure_attrs == self.unstructure_attrs_asdict
            else UnstructureStrategy.AS_TUPLE
        )
150513
def _transform_attrs(cls, these, auto_attribs, kw_only):
    
    cd = cls.__dict__
    anns = _get_annotations(cls)

    if these is not None:
        ca_list = [(name, ca) for name, ca in iteritems(these)]

        if not isinstance(these, ordered_dict):
            ca_list.sort(key=_counter_getter)
    elif auto_attribs is True:
        ca_names = {
            name
            for name, attr in cd.items()
            if isinstance(attr, _CountingAttr)
        }
        ca_list = []
        annot_names = set()
        for attr_name, type in anns.items():
            if _is_class_var(type):
                continue
            annot_names.add(attr_name)
            a = cd.get(attr_name, NOTHING)
            if not isinstance(a, _CountingAttr):
                if a is NOTHING:
                    a = attrib()
                else:
                    a = attrib(default=a)
            ca_list.append((attr_name, a))

        unannotated = ca_names - annot_names
        if len(unannotated) > 0:
            raise UnannotatedAttributeError(
                "The following `attr.ib`s lack a type annotation: "
                + ", ".join(
                    sorted(unannotated, key=lambda n: cd.get(n).counter)
                )
                + "."
            )
    else:
        ca_list = sorted(
            (
                (name, attr)
                for name, attr in cd.items()
                if isinstance(attr, _CountingAttr)
            ),
            key=lambda e: e[1].counter,
        )

    own_attrs = [
        Attribute.from_counting_attr(
            name=attr_name, ca=ca, type=anns.get(attr_name)
        )
        for attr_name, ca in ca_list
    ]

    base_attrs = []
    base_attr_map = {}  # A dictionary of base attrs to their classes.
    taken_attr_names = {a.name: a for a in own_attrs}

    # Traverse the MRO and collect attributes.
    for base_cls in cls.__mro__[1:-1]:
        sub_attrs = getattr(base_cls, "__attrs_attrs__", None)
        if sub_attrs is not None:
            for a in sub_attrs:
                prev_a = taken_attr_names.get(a.name)
                # Only add an attribute if it hasn't been defined before.  This
                # allows for overwriting attribute definitions by subclassing.
                if prev_a is None:
                    base_attrs.append(a)
                    taken_attr_names[a.name] = a
                    base_attr_map[a.name] = base_cls

    attr_names = [a.name for a in base_attrs + own_attrs]

    AttrsClass = _make_attr_tuple_class(cls.__name__, attr_names)

    if kw_only:
        own_attrs = [a._assoc(kw_only=True) for a in own_attrs]
        base_attrs = [a._assoc(kw_only=True) for a in base_attrs]

    attrs = AttrsClass(base_attrs + own_attrs)

    had_default = False
    was_kw_only = False
    for a in attrs:
        if (
            was_kw_only is False
            and had_default is True
            and a.default is NOTHING
            and a.init is True
            and a.kw_only is False
        ):
            raise ValueError(
                "No mandatory attributes allowed after an attribute with a "
                "default value or factory.  Attribute in question: %r" % (a,)
            )
        elif (
            had_default is False
            and a.default is not NOTHING
            and a.init is not False
            and
            # Keyword-only attributes without defaults can be specified
            # after keyword-only attributes with defaults.
            a.kw_only is False
        ):
            had_default = True
        if was_kw_only is True and a.kw_only is False and a.init is True:
            raise ValueError(
                "Non keyword-only attributes are not allowed after a "
                "keyword-only attribute (unless they are init=False).  "
                "Attribute in question: {a!r}".format(a=a)
            )
        if was_kw_only is False and a.init is True and a.kw_only is True:
            was_kw_only = True

    return _Attributes((attrs, base_attrs, base_attr_map))
336334
def unwrap(obj, attr):
    
    f = getattr(obj, attr, None)
    if f and isinstance(f, wrapt.ObjectProxy) and hasattr(f, '__wrapped__'):
        setattr(obj, attr, f.__wrapped__)
339566
def _set_default_attr(self, default_attr):
        
        for attr, val in six.iteritems(default_attr):
            if getattr(self, attr, None) is None:
                setattr(self, attr, val)
279446
def attrs(
    maybe_cls=None, type=None, context=None, translate=None, **attrs_kwargs
):
    """"""
    if isinstance(type, (list, tuple, set)):
        types = list(type)
    else:
        types = [type] if type is not None else []
    context = context or {}
    translate = translate or {}

    def wrap(cls):
        """Decorate an attr enabled class."""
        jsonld_cls = attr.s(cls, **attrs_kwargs)

        if not issubclass(jsonld_cls, JSONLDMixin):
            jsonld_cls = attr.s(
                make_type(cls.__name__, (jsonld_cls, JSONLDMixin), {}),
                **attrs_kwargs
            )

        # Merge types
        for subcls in jsonld_cls.mro():
            subtype = getattr(subcls, '_jsonld_type', None)
            if subtype:
                if isinstance(subtype, (tuple, list)):
                    types.extend(subtype)
                else:
                    types.append(subtype)

            for key, value in getattr(subcls, '_jsonld_context', {}).items():
                if key in context and context[key] != value:
                    raise TypeError()
                context.setdefault(key, value)

        for a in attr.fields(jsonld_cls):
            key = a.name
            ctx = a.metadata.get(KEY)
            if ctx is None:
                continue

            if ':' in ctx:
                prefix, _ = ctx.split(':', 1)
                if prefix in context:
                    context[key] = ctx
                    continue

            if isinstance(ctx, dict) or ctx not in context:
                context[key] = ctx

            if KEY_CLS in a.metadata:
                merge_ctx = a.metadata[KEY_CLS]._jsonld_context
                for ctx_key, ctx_value in merge_ctx.items():
                    context.setdefault(ctx_key, ctx_value)
                    if context[ctx_key] != ctx_value:
                        raise TypeError(
                            'Can not merge {0} and {1} because of {2}'.format(
                                jsonld_cls, a.metadata[KEY_CLS], ctx_key
                            )
                        )

        jsonld_cls.__module__ = cls.__module__
        jsonld_cls._jsonld_type = types[0] if len(types) == 1 else list(
            sorted(set(types))
        )
        jsonld_cls._jsonld_context = context
        jsonld_cls._jsonld_translate = translate
        jsonld_cls._jsonld_fields = {
            a.name
            for a in attr.fields(jsonld_cls) if KEY in a.metadata
        }

        context_doc = '\n'.join(
            '   ' + line for line in json.dumps(context, indent=2).split('\n')
        )
        jsonld_cls.__doc__ = DOC_TPL.format(
            cls=cls,
            type=json.dumps(jsonld_cls._jsonld_type),
            context=context_doc,
        )

        # Register class for given JSON-LD @type
        try:
            type_ = ld.expand({
                '@type': jsonld_cls._jsonld_type,
                '@context': context
            })[0]['@type']
            if isinstance(type_, list):
                type_ = tuple(sorted(type_))
        except Exception:
            # FIXME make sure all classes have @id defined
            return jsonld_cls

        if type_ in jsonld_cls.__type_registry__:
            raise TypeError(
                'Type {0!r} is already registered for class {1!r}.'.format(
                    jsonld_cls._jsonld_type,
                    jsonld_cls.__type_registry__[jsonld_cls._jsonld_type],
                )
            )
        jsonld_cls.__type_registry__[type_] = jsonld_cls
        return jsonld_cls

    if maybe_cls is None:
        return wrap
    return wrap(maybe_cls)
733177
def _initialize_attributes(model_class, name, bases, attrs):
    """"""
    model_class._attributes = {}
    for k, v in attrs.iteritems():
        if isinstance(v, Attribute):
            model_class._attributes[k] = v
            v.name = v.name or k
1175035
def _rules_attr(cls):
        """"""
        from qnet.algebra.core.algebraic_properties import (
            match_replace, match_replace_binary)
        if match_replace in cls.simplifications:
            return '_rules'
        elif match_replace_binary in cls.simplifications:
            return '_binary_rules'
        else:
            raise TypeError(
                "class %s does not have match_replace or "
                "match_replace_binary in its simplifications" % cls.__name__)
206747
function _removeAttr($attr, &$attributes)
    {
        $attr = strtolower($attr);
        if (isset($attributes[$attr])) {
            unset($attributes[$attr]);
        }
    }
151479
function(attrs) {
        var ret = {};
        if (this._getAttrs) { // use Attribute imple
            this._getAttrs(attrs);
        } else { // use setters inline
            Y.Array.each(attrs, function(v, n) {
                ret[v] = this.get(v); 
            }, this);
        }

        return ret;
    }
1270087
function attrsToString(attrs) {
  return Object.keys(attrs)
    .map(key => `${key}="${attrs[key]}"`)
    .join(' ');
}
202019
def reset_attribute!(attr)
      attr = database_field_name(attr)
      attributes[attr] = changed_attributes.delete(attr) if attribute_changed?(attr)
    end
365616
def _reset_lazymodule(module, cls_attrs):
    
    modclass = type(module)
    del modclass.__getattribute__
    del modclass.__setattr__
    try:
        del modclass._LOADING
    except AttributeError:
        pass
    for cls_attr in _CLS_ATTRS:
        try:
            setattr(modclass, cls_attr, cls_attrs[cls_attr])
        except KeyError:
            pass
    _reset_lazy_submod_refs(module)
210117
def _init_optional_attrs(optional_attrs):
        """"""
        if optional_attrs is None:
            return None
        opts = OboOptionalAttrs.get_optional_attrs(optional_attrs)
        if opts:
            return OboOptionalAttrs(opts)
787810
def attrs(self) -> Mapping:
        
        if self._attrs is None:
            self._attrs = OrderedDict()
        return self._attrs
1161565
private List<Attribute> removeEmptyAndOverrideAttrs(List<Attribute> attrs) {
        if (attrs == null)
            return null;
        List<Attribute> toKeep = new ArrayList<Attribute>();
        for (Attribute attr : attrs) {
            if (attr.getAttributeName() != null && attr.getAttributeName().trim().length() > 0 &&
                    attr.getAttributeValue() != null && attr.getAttributeValue().trim().length() > 0 &&
                    !WorkAttributeConstant.isOverrideAttribute(attr.getAttributeName()) &&
                    !attr.getAttributeName().equals("REFERENCED_ACTIVITIES") &&
                    !attr.getAttributeName().equals("REFERENCED_PROCESSES")) {
                toKeep.add(attr);
            }
        }
        return toKeep;
    }
238270
def fill_attrs(self, attrs):
        """"""
        for trname, attrname in self.transitions_at.items():

            implem = self.implementations[trname]

            if attrname in attrs:
                conflicting = attrs[attrname]
                if not self._may_override(implem, conflicting):
                    raise ValueError(
                        "Can't override transition implementation %s=%r with %r" %
                        (attrname, conflicting, implem))

            attrs[attrname] = implem
        return attrs
594822
def _unmangle_attribute_name(name):
    """"""

    # Python keywords cannot be used as variable names, an underscore should
    # be appended at the end of each of them when defining attribute names.
    name = _PYTHON_KEYWORD_MAP.get(name, name)

    # Attribute names are mangled with double underscore, as colon cannot
    # be used as a variable character symbol in Python. Single underscore is
    # used for substituting dash.
    name = name.replace('__', ':').replace('_', '-')

    return name