def _normalize_attrs(attrs, null=None):
  """Returns an OrderedDict of attirbutes with the keys normalized by _normalize_name and the values
  normalized by _normalize_value. The value of :null: is passed to _normalize_value. However, if
  :null: is None, any values that are None are left out of the returned dict.

  An OrderedDict is returned so that the attributes are always printed in the same order for similar
  objects.

  :attrs: a dict whose keys can be passed to _normalize_name and whose values can be passed to
          _normalize_value
  :null: either a string to be put in place of values that are None, or None, which will cause
         values that are None to be left out of the returned dict
  """
  if attrs:
    items = sorted((_normalize_name(k), _normalize_value(v, null)) for (k, v) in attrs.items())

    if null is None:
      return OrderedDict((k, v) for (k, v) in items if v is not None)
    else:
      return OrderedDict(items)
  else:
    return {}