temptree
Generates temporary files and directories from a tree.
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:
inv -l
Use the pre-commit task within your repository pre-commit hook:
poetry run invoke pre-commit
Contributing
This project is hosted on Github.
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.
License
temptree is licensed under the GNU GPL 3 or later.
Metadata
Release files for temptree 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| temptree-0.2.1.tar.gz | 17.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| temptree-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.0 kB
Release files / temptree-0.2.1.tar.gz
| Download URL | temptree-0.2.1.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae257de006cba156dfaee9fb9b2cf27bc836ccac45f99a4908e3bd024e1f12f7
|
|
BLAKE2b-256 checksum How to use checksums |
a9dc6810b8bc401cbf294771c29334769f335e81a4b8170218b372a90ca06f9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.17 CPython/3.7.4 Linux/5.2.14-arch2-1-ARCH
|
Release files / temptree-0.2.1-py3-none-any.whl
| Download URL | temptree-0.2.1-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1fcc7eff81d74b30143d98cef1a5b1723a17b32ca2ef668f41c0bd29b742d0cb
|
|
BLAKE2b-256 checksum How to use checksums |
bf59f4462fa08042c1cd94f21f20e33d6ff416a0f306c4c84e192fe85aaff3f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.17 CPython/3.7.4 Linux/5.2.14-arch2-1-ARCH
|