# -*- coding: utf-8 -*-
from setuptools import setup

modules = \
['tdir']
install_requires = \
['dek>=1.0.2,<2.0.0', 'xmod>=1.3.2,<2.0.0']

setup_kwargs = {
    'name': 'tdir',
    'version': '1.4.1',
    'description': '🗃 tdir - create and fill a temporary directory 🗃',
    'long_description': "🗃 tdir - create and fill a temporary directory 🗃\n======================================================\n\nRun code inside a temporary directory filled with zero or more files.\n\nVery convenient for writing tests: you can decorate individual tests or a whole\ntest suite.\n\n``tdir()`` runs code in a temporary directory pre-filled with files: it can\neither be used as a context manager, or a decorator for functions or classes.\n\n``tdir.fill()`` is a tiny function that recursively fills a directory.\n\nEXAMPLE: as a context manager\n\n.. code-block:: python\n\n    from pathlib import Path\n    import tdir\n\n    cwd = Path.cwd()\n\n    # Simplest invocation.\n\n    with tdir():\n       # Do a lot of things in a temporary directory\n\n    # Everything is gone!\n\n    # With a single file\n    with tdir('hello') as td:\n        # The file ``hello`` is there\n        assert Path('hello').read_text() = 'hello\\n'\n\n        # We're in a temporary directory\n        assert td == Path.cwd()\n        assert td != cwd\n\n        # Write some other file\n        Path('junk.txt').write_text('hello, world\\n')\n\n    # The temporary directory and the files are gone\n    assert not td.exists()\n    assert cwd == Path.cwd()\n\n    # A more complex example:\n    #\n    with tdir(\n        'one.txt',\n        three='some information',\n        four=Path('existing/file'),  # Copy a file into the tempdir\n        sub1={\n            'file.txt': 'blank lines\\n\\n\\n\\n',\n            'sub2': [\n                'a', 'b', 'c'\n            ]\n        },\n    ):\n        assert Path('one.txt').exists()\n        assert Path('four').read_text() == Path('/existing/file').read_text()\n        assert Path('sub1/sub2/a').exists()\n\n    # All files gone!\n\nEXAMPLE: as a decorator\n\n.. code-block:: python\n\n    from pathlib import Path\n    import tdir\n    import unittest\n\n    @tdir\n    def my_function():\n        pass  # my_function() always operates in a temporary directory\n\n\n    # Decorate a TestCase so each test runs in a new temporary directory\n    # with two files\n    @tdir('a', foo='bar')\n    class MyTest(unittest.TestCast):\n        def test_something(self):\n            assert Path('a').read_text() = 'a\\n'\n\n        def test_something_else(self):\n            assert Path('foo').read_text() = 'bar\\n'\n\n\n    class MyTest2(unittest.TestCast):\n        # Decorate just one test in a unitttest\n        @tdir(foo='bar', baz=bytes(range(4)))  # binary files are possible\n        def test_something(self):\n            assert Path('foo').read_text() = 'bar\\n'\n            assert Path('baz').read_bytes() = bytes(range(4)))\n\n        # Run test in an empty temporary directory\n        @tdir\n        def test_something_else(self):\n            assert not Path('a').exists()\n            assert Path().absolute() != self.ORIGINAL_PATH\n\n        ORIGINAL_PATH = Path().absolute()\n\nAPI\n---\n\nClass ``tdir``\n~~~~~~~~~~~~~~\n\n(`tdir.py, 120-220 <https://github.com/rec/tdir/blob/master/tdir.py#L120-L220>`_)\n\nSet up a temporary directory, fill it with files, then tear it down at\nthe end of an operation.\n\n``tdir`` can be used either as a context manager, or a decorator for\nfunctions or classes.\n\nARGUMENTS\n  args, kwargs:\n    Files to put into the temporary directory.\n    See the documentation for ``tdir.fill()``\n\n  chdir:\n    If true (the default), change the working directory to the tdir at\n    the start of the operation and restore the original working directory\n    at the end.  Otherwise, don't change or restore the working directory.\n\n  methods:\n    The methods argument tells how to decorate class methods when\n    decorating a class.\n\n    The default decorates only class methods that start with the string\n    ``test`` - exactly like ``unittest.mock.patch`` does.\n\n    See https://github.com/rec/dek/blob/master/README.rst#dekdekdecorator-deferfalse-methodsnone\n\n  use_dir:\n    If non-empty, ``use_dir`` is used instead of a temp directory (and is\n    not removed at the end) - for example, ``use_dir='.'`` puts everything in\n    the current directory.\n\n  save:\n    If set to true, the temp directory is not deleted at end and its name\n    is printed to ``sys.stderr``\n\n``tdir.tdir.__new__()``\n_______________________\n\n.. code-block:: python\n\n  tdir.tdir.__new__(\n       cls,\n       *args,\n       chdir=True,\n       methods='test',\n       use_dir=None,\n       save=False,\n       **kwargs,\n  )\n\n(`tdir.py, 158-190 <https://github.com/rec/tdir/blob/master/tdir.py#L158-L190>`_)\n\nCreate and return a new object.  See help(type) for accurate signature.\n\n``tdir.tdir.__call__(self, *args, **kwargs)``\n_____________________________________________\n\n(`tdir.py, 218-220 <https://github.com/rec/tdir/blob/master/tdir.py#L218-L220>`_)\n\nCall self as a function.\n\n``tdir.fill(root, *args, **kwargs)``\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n(`tdir.py, 222-286 <https://github.com/rec/tdir/blob/master/tdir.py#L222-L286>`_)\n\nRecursively fills a directory from file names and optional values.\n\nARGUMENTS\n  root:\n    The root directory to fill\n\n  args:\n    A list of strings, dictionaries or Paths.\n\n    For strings, a file is created with that string as name and contents.\n\n    For dictionaries, the contents are used to recursively create and fill\n    the directory.\n\n    For Paths, that file is copied into the target directory under the same\n    name.\n\n  kwargs:\n    A dictionary mapping file or directory names to values.\n\n    If the key's value is a string it is used to file a file of that name.\n\n    If it's a dictionary, its contents are used to recursively create and\n    fill a subdirectory.\n\n    If it's a Path, that file is copied to the target directory but with\n    the key as its name.\n\n(automatically generated by `doks <https://github.com/rec/doks/>`_ on 2020-12-03T18:26:23.830491)\n",
    'author': 'Tom Ritchford',
    'author_email': 'tom@swirly.com',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'None',
    'py_modules': modules,
    'install_requires': install_requires,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
