:param acs: List of AttributeConverter instances
    :param attr: an Attribute dictionary
    :return: The local attribute name
335731
def d_to_local_name(acs, attr):
    
    for aconv in acs:
        lattr = aconv.d_from_format(attr)
        if lattr:
            return lattr

    # if everything else fails this might be good enough
    try:
        return attr["friendly_name"]
    except KeyError:
        raise ConverterError("Could not find local name for %s" % attr)
14876
def _safe_getattr(o):
    
    def getattribute(attr): # pragma: no cover
        if hasattr(o, "__acornext__") and o.__acornext__ is not None:
            return o.__acornext__.__getattribute__(attr)
        elif hasattr(o, "__acorn__") and o.__acorn__ is not None:
            #Some of the functions have the original function (when it was not
            #extended) in the __acorn__ attribute.
            return o.__acorn__.__getattribute__(attr)
        else:
            return getattr(o, attr)
    return getattribute
564734
def getAttributeNode(self, attr: str) -> Optional[Attr]:
        
        return self.attributes.getNamedItem(attr)
1201363
def attributes(attrs):
    
    attrs = attrs or {}
    ident = attrs.get("id", "")
    classes = attrs.get("classes", [])
    keyvals = [[x, attrs[x]] for x in attrs if (x != "classes" and x != "id")]
    return [ident, classes, keyvals]
1323874
def ac_factory(path=""):
    
    acs = []

    if path:
        if path not in sys.path:
            sys.path.insert(0, path)

        for fil in os.listdir(path):
            if fil.endswith(".py"):
                mod = import_module(fil[:-3])
                for key, item in mod.__dict__.items():
                    if key.startswith("__"):
                        continue
                    if isinstance(item,
                                  dict) and "to" in item and "fro" in item:
                        atco = AttributeConverter(item["identifier"])
                        atco.from_dict(item)
                        acs.append(atco)
    else:
        from saml2 import attributemaps

        for typ in attributemaps.__all__:
            mod = import_module(".%s" % typ, "saml2.attributemaps")
            for key, item in mod.__dict__.items():
                if key.startswith("__"):
                    continue
                if isinstance(item, dict) and "to" in item and "fro" in item:
                    atco = AttributeConverter(item["identifier"])
                    atco.from_dict(item)
                    acs.append(atco)

    return acs
466948
def to_attrs(args, nocreate_if_none=['id', 'for', 'class']):
    
    if not args:
        return ''
    s = ['']
    for k, v in sorted(args.items()):
        k = u_str(k)
        v = u_str(v)
        if k.startswith('_'):
            k = k[1:]
        if v is None:
            if k not in nocreate_if_none:
                s.append(k)
        else:
            if k.lower() in __noescape_attrs__:
                t = u_str(v)
            else:
                t = cgi.escape(u_str(v))
            t = '"%s"' % t.replace('"', '&quot;')
            s.append('%s=%s' % (k, t))
    return ' '.join(s)
882456
def attr(cls, iterable, attr_name):
    

    return cls(getattr(x, attr_name) for x in iterable)
301382
def action_attr(attr_name):
    

    def action_attr(value, context, **_params):
        setattr(context["action"], attr_name, value)
        return _attr()

    return action_attr
1166624
private Attributes toAttributes(Map<String,String> attrs){
        AttributesImpl impl = new AttributesImpl();
        for (Map.Entry<String,String> attr : attrs.entrySet()){
        	impl.addAttribute("", attr.getKey(), "", "CDATA", attr.getValue());
        }
        return impl;
    }
1080316
def source_attr(attr_name):
    

    def source_attr(value, context, **_params):
        setattr(context["model"].source, attr_name, value)
        return _attr()

    return source_attr
970736
def __attr_name(self, name):
		
		if name not in self.cookie_attr_value_compliance.keys():
			suggested_name = name.replace('_', '-').lower()
			if suggested_name not in self.cookie_attr_value_compliance.keys():
				raise ValueError('Invalid attribute name is specified')
			name = suggested_name
		return name
1103169
def attributes_strToDict(astr_attributes, astr_separator=" "):
  
  adict = {}
  alist = str2lst(astr_attributes, astr_separator)
  for str_pair in alist:
    alistTuple = str2lst(str_pair, "=")
    adict.setdefault(alistTuple[0], alistTuple[1].strip(chr(0x22) + chr(0x27)))
  return adict
425067
def get_translated_attribute(instance, attr):
	
	
	# If its class has no translatable fields, returns attribute
	try:
		if not hasattr(instance._meta, "translatable_fields") or len(getattr(instance._meta,"translatable_fields"))==0:
			return getattr(instance, attr)
	except AttributeError:
		return instance
	
	# Translatable fields of this instance
	translatable_fields = instance._meta.translatable_fields

	# Current language
	cur_language = get_language()
	lang = cur_language.title().lower()

	# If current language is default language, returns attribute
	if lang == settings.LANGUAGE_CODE:
		return getattr(instance, attr)
	
	# Otherwise, if a translation is NOT needed for attr atribute, get attribute
	if not attr in translatable_fields:
		return getattr(instance, attr)

	# Gets field translations of this instance and return the translated attribute
	field_translation = _get_fieldtranslations(instance, field=attr, lang=lang)
	if field_translation:
		if not field_translation.is_fuzzy:
			return field_translation.translation
	return getattr(instance, attr)
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))
991796
def _get_attribute_components(self, att):
        

        lc = []

        if not CPEComponent.is_valid_attribute(att):
            errmsg = "Invalid attribute name '{0}' is not exist".format(att)
            raise ValueError(errmsg)

        for pk in CPE.CPE_PART_KEYS:
            elements = self.get(pk)
            for elem in elements:
                lc.append(elem.get(att))

        return lc
1308858
def attribute(attr)
      return super unless self.class.metadata_column_fields.include?(attr.to_sym)

      options = self.class.metadata_column_fields[attr.to_sym] || {}
      default = options.include?(:default) ? options[:default] : nil
      _metadata_hash.include?(attr) ? HasMetadataColumn.metadata_typecast(_metadata_hash[attr], options[:type]) : default
    end
44647
def lookup_attribute_chain(attrname, namespace):
    
    #subdict = meta_util_six.get_funcglobals(root_func)
    subtup = attrname.split('.')
    subdict = namespace
    for attr in subtup[:-1]:
        subdict = subdict[attr].__dict__
    leaf_name = subtup[-1]
    leaf_attr = subdict[leaf_name]
    return leaf_attr