Preserve attr data for combining B into A.
483033
def preserve_attr_data(A, B):
    '''
    '''
    for attr, B_data in B.items(): # defined object attrs
        if getattr(B_data, 'override_parent', True):
            continue
        if attr in A:
            A_data = A[attr]
            for _attr in getattr(A_data, '_attrs', []): # Attr attrs, like type, default, & doc
                if hasattr(A_data, _attr):
                    if getattr(B_data, _attr, None) is not None:
                        if _attr in getattr(B_data, '_set_by_default', []):
                            setattr(B_data, _attr, getattr(A_data, _attr))
                    else:
                        setattr(B_data, _attr, getattr(A_data, _attr))
934724
def merge_attrs(list_of_attrs):
    
    result = DEFAULT_ATTRS

    for attr in list_of_attrs:
        result = Attrs(
            color=attr.color or result.color,
            bgcolor=attr.bgcolor or result.bgcolor,
            bold=attr.bold or result.bold,
            underline=attr.underline or result.underline,
            italic=attr.italic or result.italic,
            blink=attr.blink or result.blink,
            reverse=attr.reverse or result.reverse)

    return result
627633
def attrfindrows(self, groupname, attrname, value):
        """"""
        values = self.attrgetcol(groupname, attrname)
        return [i for i in range(len(values)) if values[i] == value]
585244
def _combine(self, applied, shortcut=False):
        """"""
        applied_example, applied = peek_at(applied)
        coord, dim, positions = self._infer_concat_args(applied_example)
        if shortcut:
            combined = self._concat_shortcut(applied, dim, positions)
        else:
            combined = concat(applied, dim)
            combined = _maybe_reorder(combined, dim, positions)

        if isinstance(combined, type(self._obj)):
            # only restore dimension order for arrays
            combined = self._restore_dim_order(combined)
        if coord is not None:
            if shortcut:
                combined._coords[coord.name] = as_variable(coord)
            else:
                combined.coords[coord.name] = coord
        combined = self._maybe_restore_empty_groups(combined)
        combined = self._maybe_unstack(combined)
        return combined
171132
def flatatt(self, **attr):
        ''''''
        cs = ''
        attr = self._attr
        classes = self._classes
        data = self._data
        css = self._css
        attr = attr.copy() if attr else {}
        if classes:
            cs = ' '.join(classes)
            attr['class'] = cs
        if css:
            attr['style'] = ' '.join(('%s:%s;' % (k, v) for
                                      k, v in css.items()))
        if data:
            for k, v in data.items():
                attr['data-%s' % k] = dump_data_value(v)
        if attr:
            return ''.join(attr_iter(attr))
        else:
            return ''
1366419
def structure_attrs_fromtuple(self, obj, cl):
        # type: (Tuple, Type[T]) -> T
        """"""
        conv_obj = []  # A list of converter parameters.
        for a, value in zip(cl.__attrs_attrs__, obj):  # type: ignore
            # We detect the type by the metadata.
            converted = self._structure_attr_from_tuple(a, a.name, value)
            conv_obj.append(converted)

        return cl(*conv_obj)
662634
def _wrap_attribute(self, attr):
        """"""
        if not attr:
            const = const_factory(attr)
            const.parent = self
            return const
        return attr
1152198
def merge_attributes(attr1, attr2):
    

    new_d = copy.deepcopy(attr1)
    new_d.update(attr2)

    #all of attr2 key : values just overwrote attr1, fix it
    for k, v in new_d.items():
        if not isinstance(v, list):
            new_d[k] = [v]

    for k, v in six.iteritems(attr1):
        if k in attr2:
            if not isinstance(v, list):
                v = [v]
            new_d[k].extend(v)
    return dict((k, sorted(set(v))) for k, v in new_d.items())
882456
def attr(cls, iterable, attr_name):
    

    return cls(getattr(x, attr_name) for x in iterable)
1080395
def combine(self, a, b):
        """"""

        for l in (a, b):
            for x in l:
                yield x
149813
def make_attributes(s, gff3=True, keep_attr_order=True):
    
    if gff3:
        """
        hack: temporarily replace the '+' sign in the attributes column
        with the string 'PlusSign' to prevent urlparse.parse_qsl() from
        replacing the '+' sign with a space
        """
        s = s.replace('+', 'PlusSign')
        d = parse_qs(s, keep_attr_order=keep_attr_order)
        for key in d:
            d[key][0] = unquote(d[key][0].replace('PlusSign', '+').replace('"', ''))
    else:
        attributes = s.split(";")
        d = DefaultOrderedDict(list) if keep_attr_order else defaultdict(list)
        for a in attributes:
            a = a.strip()
            if ' ' not in a:
                continue
            key, val = a.split(' ', 1)
            val = unquote(val.replace('"', '').replace('=', ' ').strip())
            d[key].append(val)

    for key, val in d.items():
        d[key] = list(flatten([v.split(",") for v in val]))

    return d
1066258
def _merge_fields(a, b):
    

    a_names = set(x[0] for x in a)
    b_names = set(x[0] for x in b)
    a_keep = a_names - b_names

    fields = []

    for name, field in a:
        if name in a_keep:
            fields.append((name, field))

    fields.extend(b)

    return fields
1265129
def on_slim_attrvalue(escape, code)
      # We perform attribute merging on Array values
      if delimiter = options[:merge_attrs][@attr]
        tmp = unique_name
        [:multi,
         [:code, "#{tmp} = #{code}"],
         [:if, "Array === #{tmp}",
          [:multi,
           [:code, "#{tmp} = #{tmp}.flatten"],
           [:code, "#{tmp}.map!(&:to_s)"],
           [:code, "#{tmp}.reject!(&:empty?)"],
           [:escape, escape, [:dynamic, "#{tmp}.join(#{delimiter.inspect})"]]],
          [:escape, escape, [:dynamic, tmp]]]]
      else
        [:escape, escape, [:dynamic, code]]
      end
    end
32434
function attr(obj, key) {
    if (!obj[key]) {
      return '';
    }
    var val = obj[key];
    if (val === true) {
      return key;
    }
    return key + '="' + obj[key] + '"';
  }
523062
def _merge_user_attrs(self, attrs_backend, attrs_out, backend_name):
        
        for attr in attrs_backend:
            if attr in self.attributes.backend_attributes[backend_name]:
                attrid = self.attributes.backend_attributes[backend_name][attr]
                if attrid not in attrs_out:
                    attrs_out[attrid] = attrs_backend[attr]
1086590
def _set_hwxy_attrs(attr):
        
        bbox = attr['bbox']
        attr['x0'] = bbox[0]
        attr['x1'] = bbox[2]
        attr['y0'] = bbox[1]
        attr['y1'] = bbox[3]
        attr['height'] = attr['y1'] - attr['y0']
        attr['width'] = attr['x1'] - attr['x0']
        return attr
667002
function merge(obj1, obj2) {
  var res = {}, attrname;

  for (attrname in obj1) {
    res[attrname] = obj1[attrname];
  }
  for (attrname in obj2) {
    res[attrname] = obj2[attrname];
  }
  return res;
}