tempf - TempFiles
Multiple temporary files in 1 line of code.
TempFiles(X) returns a tuple of X non-used paths.
from tempf import TempFiles
with TempFiles(3) as (path1, path2, path3):
with path1.open('w') as file1:
file1.write('See how easy it is?')
Install
>>> pip install tempf
Example
Compilation process:
from pathlib import Path
from tempf import TempFiles
def compile_run_and_check_output(code_path: Path, expected_output: str) -> bool:
"""
Compile the code, run it, and assert the output is as expected.
:param code_path: The path to the code to compile.
:param expected_output: The expected output from running the code.
:returns: True if compilation and run went successful, and the run outputted the expected output.
"""
with TempFiles(4) as (compile_log_path, run_log_path, executable_path, run_output_path):
compile_file(code_path, log=compile_log_path, compiled=executable_path)
if not is_compile_log_ok(compile_log_path):
return False
run_compiled(executable_path, log=run_log_path, run_output=run_output_path)
if not is_run_log_ok(run_log_path):
return False
with run_output_path.open('r') as output_file:
return expected_output == output_file.read()
Metadata
Release files for tempf 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tempf-1.0.0.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tempf-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.4 kB
Release files / tempf-1.0.0.tar.gz
| Download URL | tempf-1.0.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3c0bc67b20ab1f5acdb9c4d0d95c82af7475fecebd8dc68a64f0e05bd9fe653
|
|
BLAKE2b-256 checksum How to use checksums |
2936c7932bef0fa4aaea7426e2257b8a2bcbd8b6e5faef20dc0a1a3b5a77f072
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1016-azure
|
Release files / tempf-1.0.0-py3-none-any.whl
| Download URL | tempf-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2689134f8c87d051ea37883a1805784ea56372947ffca772d70a4811065cdfbf
|
|
BLAKE2b-256 checksum How to use checksums |
5f6611df3b2d6d57fdebcb1c2ffbba1455f3b6e5403e3e34e77567c7d299e3e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1016-azure
|