def kwattr(d, name, default=None):
    """Return attribute, converted to lowercase."""
    v = d.get(name, default)
    if v != default and v is not None:
        v = v.strip().lower()
        v = v or default
    return v