Atrribute and value pair parser.

    :param str_: String represents a list of pairs of attribute and value
    :param avs_sep: char to separate attribute and values
    :param vs_sep: char to separate values
    :param as_sep: char to separate attributes
183305
def attr_val_itr(str_, avs_sep=":", vs_sep=",", as_sep=";"):
    
    for rel in parse_list(str_, as_sep):
        if avs_sep not in rel or rel.endswith(avs_sep):
            continue

        (_attr, _values) = parse_list(rel, avs_sep)

        if vs_sep in str(_values):
            _values = parse_list(_values, vs_sep)

        if _values:
            yield (_attr, _values)
1273114
def _to_s(val, sep=", "):
    
    if anyconfig.utils.is_iterable(val):
        return sep.join(str(x) for x in val)

    return str(val)
80141
def normalize_attr_strings(a: np.ndarray) -> np.ndarray:
	
	if np.issubdtype(a.dtype, np.object_):
		# if np.all([type(x) is str for x in a]) or np.all([type(x) is np.str_ for x in a]) or np.all([type(x) is np.unicode_ for x in a]):
		if np.all([(type(x) is str or type(x) is np.str_ or type(x) is np.unicode_) for x in a]):
			return np.array([x.encode('ascii', 'xmlcharrefreplace') for x in a])
		elif np.all([type(x) is np.string_ for x in a]) or np.all([type(x) is np.bytes_ for x in a]):
			return a.astype("string_")
		else:
			logging.debug(f"Attribute contains mixed object types ({np.unique([str(type(x)) for x in a])}); casting all to string")
			return np.array([str(x) for x in a], dtype="string_")
	elif np.issubdtype(a.dtype, np.string_) or np.issubdtype(a.dtype, np.object_):
		return a
	elif np.issubdtype(a.dtype, np.str_) or np.issubdtype(a.dtype, np.unicode_):
		return np.array([x.encode('ascii', 'xmlcharrefreplace') for x in a])
	else:
		raise ValueError("String values must be object, ascii or unicode.")
784
def setattrdeep(obj, attr, val):
    ''
    attrs = attr.split('.')

    for a in attrs[:-1]:
        obj = getattr(obj, a)
    setattr(obj, attrs[-1], val)
1194322
def incr_obj(obj, **attrs):
    
    for name, value in attrs.iteritems():
        v = getattr(obj, name, None)
        if not hasattr(obj, name) or v is None:
            v = 0
        setattr(obj, name, v + value)
1121604
public static String join(final String sep, final String... strs) {
        return join(sep, Arrays.asList(strs));
    }
228712
def from_string_pairs(cls, string_value_pairs, **kwargs):
        
        return cls(re_value_pairs=[(re.compile(s), v)
                                   for s, v in string_value_pairs],
                   **kwargs)
611708
def as_struct
      attributes = { type: @type, name: @name, scope: 'local' }

      # If the value is an array, we need to build it in the somewhat silly
      # manner that vCO requires it to be presented. Otherwise, just paste
      # it on the end of the hash.
      if @type.eql?('Array')
        fail(IOError, ERR[:wtf]) unless @value.is_a?(Array)
        attributes[:value] = { @type.downcase => { elements: [] } }
        @value.each { |val| attributes[:value][@type.downcase][:elements] << { @subtype => { value: val } } }
      else
        attributes[:value] = { @type => { value: @value } }
      end
      attributes
    end
1216872
def parse_attributes(self, attrstring):
        
        if attrstring in [None, '', '.']:
            return dict()

        attributes = dict()
        keyvaluepairs = attrstring.split(';')
        for kvp in keyvaluepairs:
            if kvp == '':
                continue
            key, value = kvp.split('=')
            if key == 'ID':
                assert ',' not in value
                attributes[key] = value
                continue
            values = value.split(',')
            valdict = dict((val, True) for val in values)
            attributes[key] = valdict
        return attributes
959896
def covstr(strings):
    
    try:
        result = int(strings)
    except ValueError:
        result = float(strings)
    return result
504733
def attr_sep(self, new_sep: str) -> None:
        
        self._attr_sep = new_sep
        self._filters_tree = self._generate_filters_tree()
801672
def parse_str(self, s):
        
        root = ET.fromstring(s)
        return self._parse(root)
1207483
def str_to_list(
    input_str,
    item_converter=lambda x: x,
    item_separator=',',
    list_to_collection_converter=None,
):
    
    if not isinstance(input_str, six.string_types):
        raise ValueError(input_str)
    input_str = str_quote_stripper(input_str)
    result = [
        item_converter(x.strip())
        for x in input_str.split(item_separator) if x.strip()
    ]
    if list_to_collection_converter is not None:
        return list_to_collection_converter(result)
    return result
373602
def aslist(obj, sep=None, strip=True):
    
    if isinstance(obj, (basestring)):
        lst = obj.split(sep)
        if strip:
            lst = [v.strip() for v in lst]
        return lst
    elif isinstance(obj, (list, tuple)):
        return obj
    elif obj is None:
        return []
    else:
        return [obj]
1223177
def to_(self, attrvals):
        
        attributes = []
        for key, value in attrvals.items():
            key = key.lower()
            attributes.append(factory(saml.Attribute,
                                      name=key,
                                      name_format=self.name_format,
                                      attribute_value=do_ava(value)))

        return attributes
506021
def decode_numpy_dict_values(attrs: Mapping[K, V]) -> Dict[K, V]:
    
    attrs = dict(attrs)
    for k, v in attrs.items():
        if isinstance(v, np.ndarray):
            attrs[k] = v.tolist()
        elif isinstance(v, np.generic):
            attrs[k] = v.item()
    return attrs
438248
def str2lst(astr_input, astr_separator=" "):
  
  alistI = astr_input.split(astr_separator)
  alistJ = []
  for i in range(0, len(alistI)):
    alistI[i] = alistI[i].strip()
    alistI[i] = alistI[i].encode('ascii')
    if len(alistI[i]):
      alistJ.append(alistI[i])
  return alistJ