def dump(data, filepath):
    '''
    Write data as as type self.ext to filepath. json or .msgpack
    '''
    if filepath in ' ':
        raise IOError("Invalid filepath '{0}' "
                                "contains space".format(filepath))

    root, ext = os.path.splitext(filepath)
    if ext == '.json':
        with ocfn(filepath, "w+") as f:
            json.dump(data, f, indent=2)
            f.flush()
            os.fsync(f.fileno())
    elif ext == '.msgpack':
        if not msgpack:
            raise IOError("Invalid filepath ext '{0}' "
                        "needs msgpack installed".format(filepath))
        with ocfn(filepath, "w+b", binary=True) as f:
            msgpack.dump(data, f)
            f.flush()
            os.fsync(f.fileno())
    else:
        raise IOError("Invalid filepath ext '{0}' "
                    "not '.json' or '.msgpack'".format(filepath))
dataset/ETHPy150Open ioflo/ioflo/ioflo/aid/filing.py/dump/swapped operands of `in`