def test__write_and_op_on_tmp__and__sopen(): smpldata = "data\ndata\n" * 3 def readtmp(fname): with utils.sopen(fname, mode="r") as fp: return fp.read() assert smpldata == utils.write_and_op_on_tmp(smpldata, function=readtmp, suffix=".txt")
def parse_binary_from_string(string, suffix=None, **xargs): """ suffix = extension """ if not suffix: LOG.debug('Extension not provided, trying guess based on mime time.') suffix = guess_ext_from_mime(string) return write_and_op_on_tmp(data=string, function=parse_binary_from_file, suffix=suffix)