/* 
Map the following syntax to corresponding attrs:

<recycle-list for="(item, i) in longList" switch="cellType">
<cell-slot case="A"> ... </cell-slot>
<cell-slot case="B"> ... </cell-slot>
</recycle-list>
764066
function preTransformRecycleList (
  el,
  options
) {
  var exp = getAndRemoveAttr(el, 'for');
  if (!exp) {
    if (options.warn) {
      options.warn("Invalid <recycle-list> syntax: missing \"for\" expression.");
    }
    return
  }

  var res = parseFor(exp);
  if (!res) {
    if (options.warn) {
      options.warn(("Invalid <recycle-list> syntax: " + exp + "."));
    }
    return
  }

  addRawAttr(el, ':list-data', res.for);
  addRawAttr(el, 'binding-expression', res.for);
  addRawAttr(el, 'alias', res.alias);
  if (res.iterator2) {
    // (item, key, index) for object iteration
    // is this even supported?
    addRawAttr(el, 'index', res.iterator2);
  } else if (res.iterator1) {
    addRawAttr(el, 'index', res.iterator1);
  }

  var switchKey = getAndRemoveAttr(el, 'switch');
  if (switchKey) {
    addRawAttr(el, 'switch', switchKey);
  }
}
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
375996
function makeAttributesString(tag, profile) {
		var attrs = '';
		var otherAttrs = [];
		var attrQuote = profile.attributeQuote();
		var cursor = profile.cursor();
		
		tag.attributeList().forEach(function(a) {
			var attrName = profile.attributeName(a.name);
			switch (attrName.toLowerCase()) {
				// use short notation for ID and CLASS attributes
				case 'id':
					attrs += '#' + (a.value || cursor);
					break;
				case 'class':
					attrs += '.' + transformClassName(a.value || cursor);
					break;
				// process other attributes
				default:
					otherAttrs.push({
						name: attrName,
						value: a.value || cursor,
						isBoolean: profile.isBoolean(a.name, a.value)
					});
			}
		});
		
		if (otherAttrs.length) {
			attrs += stringifyAttrs(condenseDataAttrs(otherAttrs), profile);
		}
		
		return attrs;
	}
233081
function _attr(el, attr, attrs, i) {
        var result = (el.getAttribute && el.getAttribute(attr)) || 0;

        if (!result) {
            attrs = el.attributes;

            for (i = 0; i < attrs.length; ++i) {
                if (attrs[i].nodeName === attr) {
                    return attrs[i].nodeValue;
                }
            }
        }

        return result;
    }
698782
function processAttributeArray(attrArray) {
  let attrs = {
    'static': {},
    'dynamic': []
  };
  let name = [];
  let value = [];
  let item;
  let pushingTo = name;
  for (let i = 0; i < attrArray.length; i++) {
    item = attrArray[i];
    if (item.type === 'attributenameend') {
      pushingTo = value;
    } else if (item.type === 'attributeend') {
      // Ensure there are no tokens in a non-dynamic attribute name
      for (let j = 0; j < name.length; j++) {
        if (typeof name[j] !== 'string') {
          compilerErrors.mustacheTokenCannotBeInAttributeNames(name[j]);
        }
      }

      if (name.length === 1) {
        if (value.length) {
          if (value.length === 1 && typeof value[0] === 'string') {
            value = value[0];
          }
        } else {
          value = true;
        }
        attrs.static[name[0]] = flattenAttributeValues(value);
      } else {
        attrs.dynamic = attrs.dynamic.concat(_.map(name, flattenAttributeValues));
        if (value.length) {
          attrs.dynamic.push('="');
          attrs.dynamic = attrs.dynamic.concat(_.map(value, flattenAttributeValues));
          attrs.dynamic.push('"');
        }
      }
      name = [];
      value = [];
      pushingTo = name;
    } else if (item.type === 'attributename' || item.type === 'attributevalue') {
      pushingTo.push(item.value);
    } else if (pushingTo === name) {
      if (name.length === 0) {
        if (item.type === types.INTERPOLATOR) {
          compilerErrors.doubleCurlyInterpolatorsCannotBeInAttributes(item.value);
        } else if (item.type === types.SECTION) {
          attrs.dynamic.push(templateStack.processObject(item));
          continue;
        }
      }
      pushingTo.push(item);
    } else {
      pushingTo.push(item);
    }
  }

  attrs.dynamic = attrs.dynamic.concat(_.map(name, flattenAttributeValues));
  attrs.dynamic = attrs.dynamic.concat(_.map(value, flattenAttributeValues));
  mergeStrings(attrs.dynamic);

  return attrs;
}
426039
function rebuildAttribute (attrib, data, itemSize) {
  if (attrib.itemSize !== itemSize) return true
  if (!attrib.array) return true
  var attribLength = attrib.array.length
  if (Array.isArray(data) && Array.isArray(data[0])) {
    // [ [ x, y, z ] ]
    return attribLength !== data.length * itemSize
  } else {
    // [ x, y, z ]
    return attribLength !== data.length
  }
  return false
}
488684
function( target, attr ) {
    if ( typeof attr !== 'object' )  return
    var len = attr.length

    // Native `NamedNodeMap``:
    if (
      typeof attr[0] === 'object' &&
      'name' in attr[0]
    ) {
      for ( var i = 0; i < len; i++ ) {
        if ( attr[ i ].value !== undefined ) {
          target.setAttribute( attr[ i ].name, attr[ i ].value )
        }
      }

    // Plain object:
    } else {
      for ( var name in attr ) {
        if (
          attr.hasOwnProperty( name ) &&
          attr[ name ] !== undefined
        ) {
          target.setAttribute( name, attr[ name ] )
        }
      }
    }
    return target
  }
1174289
@Override
  protected ImmutableList<String> parseElements(String s) {
    ImmutableList.Builder<String> titles = ImmutableList.builder();
    Optional<XmlElement> child = XmlConverter.getChildOpt(s, "query", "allpages");
    if (child.isPresent()) {
      for (XmlElement pageElement : child.get().getChildren("p")) {
        String title = pageElement.getAttributeValue("title");
        log.debug("Found article title: \"{}\"", title);
        titles.add(title);
      }
    }
    return titles.build();
  }
1116294
function parseAttributes(attrStr) {
    var reAttributes = /([^=<>\"\'\s]+)\s*(?:=\s*["']?([^"']*)["']?)?/g;
    var result = {};
    var match;

    if (attrStr) {
        while (match = reAttributes.exec(attrStr)) {
            result[match[1]] = match[2] || true;
        }
    }

    return result;
}
1076778
def _make_wildcard_attr_map():
    '''
    
    '''
    _xmap = {}
    for wc in OpenflowWildcard:
        if not wc.name.endswith('All') and \
            not wc.name.endswith('Mask'):
            translated = ''
            for ch in wc.name:
                if ch.isupper():
                    translated += '_' 
                    translated += ch.lower()
                else:
                    translated += ch
            _xmap[translated] = wc
    return _xmap
710658
function makeAttributesString(node, profile) {
		var attrQuote = profile.attributeQuote();
		var cursor = profile.cursor();
		
		return node.attributeList().map(function(a) {
			var isBoolean = profile.isBoolean(a.name, a.value);
			var attrName = profile.attributeName(a.name);
			var attrValue = isBoolean ? attrName : a.value;
			if (isBoolean && profile.allowCompactBoolean()) {
				return ' ' + attrName;
			}
			return ' ' + attrName + '=' + attrQuote + (attrValue || cursor) + attrQuote;
		}).join('');
	}
790914
function _objectToRDF(item) {
  var object = {};

  // convert value object to RDF
  if(_isValue(item)) {
    object.type = 'literal';
    var value = item['@value'];
    var datatype = item['@type'] || null;

    // convert to XSD datatypes as appropriate
    if(_isBoolean(value)) {
      object.value = value.toString();
      object.datatype = datatype || XSD_BOOLEAN;
    }
    else if(_isDouble(value) || datatype === XSD_DOUBLE) {
      // canonical double representation
      object.value = value.toExponential(15).replace(/(\d)0*e\+?/, '$1E');
      object.datatype = datatype || XSD_DOUBLE;
    }
    else if(_isNumber(value)) {
      object.value = value.toFixed(0);
      object.datatype = datatype || XSD_INTEGER;
    }
    else if('@language' in item) {
      object.value = value;
      object.datatype = datatype || RDF_LANGSTRING;
      object.language = item['@language'];
    }
    else {
      object.value = value;
      object.datatype = datatype || XSD_STRING;
    }
  }
  // convert string/node object to RDF
  else {
    var id = _isObject(item) ? item['@id'] : item;
    object.type = (id.indexOf('_:') === 0) ? 'blank node' : 'IRI';
    object.value = id;
  }

  return object;
}
1143249
function parseNode(attrNode, parsers, context) {
    const attrNames = Object.keys(attrNode);
    const errorContext = context.errorContext;

    Object.keys(parsers).forEach(attrName => {
        const parser = parsers[attrName];

        context.errorContext = ` (option "${attrName}"${errorContext})`;
        removeValue(attrNames, attrName);

        if (attrName in attrNode && parser !== null) {
            attrNode[attrName] = parser(attrNode[attrName], context);
        }
    });

    context.errorContext = errorContext;

    if (attrNames.length > 0) {
        throw new ImplementationError(`Invalid option "${attrNames.join(', ')}"${context.errorContext}`);
    }
}
947075
function parseSwitchCase() {
        var test, consequent = [], statement, node = new Node();

        if (matchKeyword('default')) {
            lex();
            test = null;
        } else {
            expectKeyword('case');
            test = parseExpression();
        }
        expect(':');

        while (startIndex < length) {
            if (match('}') || matchKeyword('default') || matchKeyword('case')) {
                break;
            }
            statement = parseStatementListItem();
            consequent.push(statement);
        }

        return node.finishSwitchCase(test, consequent);
    }
1112066
function(attributes, options) {
    var attrs = attributes || {};
    options || (options = {});
    this.cid = _.uniqueId('c');
    this.attributes = {};
    if (options.collection) this.collection = options.collection;
    if (options.parse) attrs = this.parse(attrs, options) || {};
    this._schema = this.schema();
    this._defaults = this.defaults(undefined, true);
    attrs = _.defaultsDeep({}, attrs, this.defaults(undefined, false));
    this.set(attrs, options);
    this.changed = {};
    this.initialize.apply(this, arguments);
  }
860595
private void handleTypeAndAttributes(Node node, Map<String, Object> elementMap) {
        // Set type
        if (node.getLocalName() != null) {
            elementMap.put("_type", node.getLocalName());
        }

        // Set the attributes
        if (node.getAttributes() != null) {
            NamedNodeMap attributeMap = node.getAttributes();
            for (int i = 0; i < attributeMap.getLength(); i++) {
                Node attribute = attributeMap.item(i);
                elementMap.put(attribute.getNodeName(), attribute.getNodeValue());
            }
        }
    }
873872
function(allOfList, definitions) {
    var length = allOfList.length,
        index = -1,
        result = {};

    while (++index < length) {
      var item = allOfList[index];

      item = (typeof item.$ref !== 'undefined') ? getLocalRef(item.$ref, definitions) : item;

      result = merge(result, item);
    }

    return result;
  }