def load(filename="", buf=None):
    """
    Unserialize data from an NBT file and return the root TAG_Compound object. If filename is passed,
    reads from the file, otherwise uses data from buf. Buf can be a buffer object with a read() method or a string
    containing NBT data.
    """
    if filename:
        buf = open(filename, "rb")
    data = buf

    if hasattr(buf, "read"):
        data = buf.read()

    result = _load_buffer(try_gunzip(data))

    if hasattr(buf, "close"):
        buf.close()

    return result

    Unserialize data from an NBT file and return the root TAG_Compound object. If filename is passed,
    reads from the file, otherwise uses data from buf. Buf can be a buffer object with a read() method or a string
    containing NBT data.
    
pymclevel/nbt.py