Skip to content

Generates temporary files and directories from a tree.

License

Notifications You must be signed in to change notification settings

neimad/temptree

Repository files navigation

temptree

Generates temporary files and directories from a tree.

Build Status PyPI Python Version License

The provided TemporaryTree class allows to create complete files hierarchies under a root tempfile.TemporaryDirectory.

It is well suited for usage within doctests :

>>> from temptree import TemporaryTree

>>> with TemporaryTree(["foo.py", "bar.py"]) as root:
...     (root / "foo.py").is_file()
...     (root / "bar.py").is_file()
...
True
True

A complete file hierarchy can be easily created, including text files content and files mode:

>>> with TemporaryTree({
...     "foo.py": ('''
...     import os
...     import sys
...
...     FOO = "foo"
...     ''', 0o700),
...     "bar": {
...         "bar.py": '''
...         import foo
...         import pathlib
...
...         def bar():
...             return foo.FOO
...         ''',
...         "baz.py": None,
...     }
... }) as root:
...     (root / "foo.py").exists()
...     (root / "bar").is_dir()
...     (root / "bar" / "bar.py").is_file()
...     (root / "bar" / "baz.py").is_file()
...
True
True
True
True

Installation

Add temptree to your project dependencies:

poetry add temptree

If you just need it within your doctests, add it as a development dependency:

poetry add --dev temptree

Documentation

The complete documentation is available from Github Pages.

Development

The development tasks are managed using Invoke. Use it to list the available tasks:

poetry run invoke --list

Install the pre-commit hook within your repository:

poetry run pre-commit install

Run the tests using Pytest:

poetry run pytest

Contributing

This project is hosted on a Github repository.

If you're facing an issue using temptree, please look at the existing tickets. Then you may open a new one.

You may also make a push request to help improve it.

Changelog

See the changelog to see what changes have been made and what you can expect in the next release.

License

temptree is licensed under the GNU GPL 3 or later.

About

Generates temporary files and directories from a tree.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages