def tar(file, dir, expression='^.+$', filenames=None):

    tar = tarfile.TarFile(file, 'w')
    try:
        if filenames is None:
            filenames = listdir(dir, expression, add_dirs=True)
        for file in filenames:
            tar.add(os.path.join(dir, file), file, False)
    finally:
        tar.close()
tars dir into file, only tars file that match expression
dataset/ETHPy150Open uwdata/termite-visualizations/web2py/gluon/fileutils.py/tar