def maybe_quote_ws(value):
    """Surrounds a value with single quotes if it contains whitespace. """
    if value is None:
        return value

    if any(x == ' ' or x == '\t' for x in value):
        return "'" + value + "'"
    return value