def _check_format(format_str):
    """Check if `format_str` is valid and return format ID."""
    if not isinstance(format_str, (_unicode, str)):
        raise TypeError("Invalid format: {0!r}".format(format_str))
    try:
        format_int = _formats[format_str.upper()]
    except __HOLE__:
        raise ValueError("Unknown format: {0!r}".format(format_str))
    return format_int
dataset/ETHPy150Open bastibe/PySoundFile/soundfile.py/_check_format