Exemple #1
0
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")
Exemple #2
0
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)