def get_filelikeobject(filename: str = None,
                       blob: bytes = None) -> BinaryIO:
    """
    Open a file-like object.

    Guard the use of this function with ``with``.

    Args:
        filename: for specifying via a filename
        blob: for specifying via an in-memory ``bytes`` object

    Returns:
        a :class:`BinaryIO` object
    """
    if not filename and not blob:
        raise ValueError("no filename and no blob")
    if filename and blob:
        raise ValueError("specify either filename or blob")
    if filename:
        return open(filename, 'rb')
    else:
        return io.BytesIO(blob)
def get_filelikeobject ( filename : str = None , blob : bytes = None ) -> BinaryIO : if not filename and not blob : raise ValueError ( "no filename and no blob" ) if filename and blob : raise ValueError ( "specify either filename or blob" ) if filename : return open ( filename , 'rb' ) else : return io . BytesIO ( blob )
Open a file-like object.

    Guard the use of this function with ``with``.

    Args:
        filename: for specifying via a filename
        blob: for specifying via an in-memory ``bytes`` object

    Returns:
        a :class:`BinaryIO` object