def str_to_bool(boolstr, default=False):
    """Convert a string to a boolean."""
    boolstr = boolstr.lower()
    if boolstr in ("true", "yes", "on", "1"):
        return True
    elif boolstr in ("false", "no", "off", "0"):
        return False
    else:
        return default