@contextlib.contextmanager
def make_layout(layout):
  tempdir = tempfile.mkdtemp()

  for filename, file_content in layout.items():
    real_path = os.path.join(tempdir, filename)
    try:
      os.makedirs(os.path.dirname(real_path))
    except __HOLE__:
      # assume EEXIST
      pass
    with open(real_path, 'w') as fp:
      fp.write(textwrap.dedent(file_content))

  try:
    yield tempdir
  finally:
    shutil.rmtree(tempdir)
dataset/ETHPy150Open wickman/pystachio/tests/test_config.py/make_layout