🗃 tdir - create and fill a temporary directory 🗃
======================================================

A context manager that creates a temporary directory using
tempfile.TemporaryDirectory and then populates it.

Extremely useful for unit tests where you want a whole directory
full of files really fast.

EXAMPLE

.. code-block:: python

    import tdir

    with tdir.tdir(
        'one', 'two', 'three',
        four='two\nlines',
        sub1={
            'six': 'A short file',
            'seven': 'blank lines\n\n\n\n',
            'eight': ['a', 'b', 'c']
    }) as td:
        # Now the directory `td` has files `one`, `two` and `three`, each with
        # one line, file `four` with two lines, and then a subdirectory `sub/`
        # with more files.

API
---

``tdir.tdir(*args, cwd=True, **kwargs)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(`tdir.py, 39-72 <https://github.com/rec/tdir/blob/master/tdir.py#L39-L72>`_)

A context that creates and fills a temporary directory

ARGUMENTS
  args:
    A list of strings or dictionaries.  For strings, a file is created
    with that string as name and contents.  For dictionaries, the contents
    are used to recursively create and fill the directory.

  cwd:
    If true, change the working directory to the temp dir at the start
    of the context and restore the original working directory at the end.

  kwargs:
    A dictionary mapping file or directory names to values.
    If the key's value is a string it is used to file a file of that name.
    If it's a dictionary, its contents are used to recursively create and
    fill a subdirectory.

``tdir.fill(root, *args, **kwargs)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(`tdir.py, 74-120 <https://github.com/rec/tdir/blob/master/tdir.py#L74-L120>`_)

Fill a directory with files containing strings

ARGUMENTS
  root:
    The root directory to fill

  args:
    A list of strings or dictionaries.  For strings, a file is created
    with that string as name and contents.  For dictionaries, the contents
    are used to recursively create and fill the directory.

  kwargs:
    A dictionary mapping file or directory names to values.
    If the key's value is a string it is used to file a file of that name.
    If it's a dictionary, its contents are used to recursively create and
    fill a subdirectory.

(automatically generated by `doks <https://github.com/rec/doks/>`_ on 2020-06-24T19:24:33.488847)
