def temporary_directory(template=None):
    """
    Require a temporary directory.

    The directory is created using the ``mktemp`` command. It will
    be created in ``/tmp``, unless the ``TMPDIR`` environment variable
    is set to another location. ::

        from fabtools.require.files import temporary_directory

        tmp_dir = temporary_directory()

    You can choose a specific location and name template for the
    temporary directory: ::

        from fabtools.require.files import temporary_directory

        tmp_dir = temporary_directory('/var/tmp/temp.XXXXXX')

    You can also call this function as a context manager. In this case,
    the directory and its contents will be automatically deleted when
    exiting the block: ::

        from pipes import quote
        from posixpath import join

        from fabtools.require.files import temporary_directory

        with temporary_directory() as tmp_dir:
            path = join(tmp_dir, 'foo')
            run('touch %s' % quote(path))

    """
    options = ['--directory']
    if template:
        options.append(template)
    options = ' '.join(options)
    with hide('running', 'stdout'):
        path = run('mktemp %s' + options)
    return TemporaryDirectory(path)
dataset/ETHPy150Open ronnix/fabtools/fabtools/require/files.py/temporary_directory/operator `%` -> `+`