tempf


Nametempf JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/tomhea/tempfiles
SummaryMultiple temporary files in 1 line of code
upload_time2023-12-01 22:32:08
maintainer
docs_urlNone
authorTom Herman
requires_python>=3.7,<4.0
licenseBSD-2-Clause-Simplified
keywords esolang oisc assembly
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tempf - TempFiles

[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/tomhea/tempfiles)](https://github.com/tomhea/tempfiles)
[![GitHub](https://img.shields.io/github/license/tomhea/flip-jump)](LICENSE)
[![PyPI - Version](https://img.shields.io/pypi/v/tempf)](https://pypi.org/project/tempf/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/tempf)](https://pypi.org/project/tempf/)


Multiple temporary files in 1 line of code. 

TempFiles(X) returns a tuple of X non-used paths.

```python
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:

```python
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()
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tomhea/tempfiles",
    "name": "tempf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "esolang,oisc,assembly",
    "author": "Tom Herman",
    "author_email": "flipjumpproject@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/29/36/c7932bef0fa4aaea7426e2257b8a2bcbd8b6e5faef20dc0a1a3b5a77f072/tempf-1.0.0.tar.gz",
    "platform": null,
    "description": "# tempf - TempFiles\n\n[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/tomhea/tempfiles)](https://github.com/tomhea/tempfiles)\n[![GitHub](https://img.shields.io/github/license/tomhea/flip-jump)](LICENSE)\n[![PyPI - Version](https://img.shields.io/pypi/v/tempf)](https://pypi.org/project/tempf/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/tempf)](https://pypi.org/project/tempf/)\n\n\nMultiple temporary files in 1 line of code. \n\nTempFiles(X) returns a tuple of X non-used paths.\n\n```python\nfrom tempf import TempFiles\n\nwith TempFiles(3) as (path1, path2, path3):\n    with path1.open('w') as file1:\n        file1.write('See how easy it is?')\n```\n\n\n## Install\n```\n>>> pip install tempf\n```\n\n\n## Example\nCompilation process:\n\n```python\nfrom pathlib import Path\nfrom tempf import TempFiles\n\n\ndef compile_run_and_check_output(code_path: Path, expected_output: str) -> bool:\n    \"\"\"\n    Compile the code, run it, and assert the output is as expected.\n    :param code_path: The path to the code to compile.\n    :param expected_output: The expected output from running the code.\n    :returns: True if compilation and run went successful, and the run outputted the expected output. \n    \"\"\"\n    with TempFiles(4) as (compile_log_path, run_log_path, executable_path, run_output_path):\n        compile_file(code_path, log=compile_log_path, compiled=executable_path)\n        if not is_compile_log_ok(compile_log_path):\n            return False\n\n        run_compiled(executable_path, log=run_log_path, run_output=run_output_path)\n        if not is_run_log_ok(run_log_path):\n            return False\n\n        with run_output_path.open('r') as output_file:\n            return expected_output == output_file.read()\n```\n",
    "bugtrack_url": null,
    "license": "BSD-2-Clause-Simplified",
    "summary": "Multiple temporary files in 1 line of code",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/tomhea/tempfiles",
        "Repository": "https://github.com/tomhea/tempfiles"
    },
    "split_keywords": [
        "esolang",
        "oisc",
        "assembly"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f6611df3b2d6d57fdebcb1c2ffbba1455f3b6e5403e3e34e77567c7d299e3e4",
                "md5": "5a7eb5157c4b86ae83bc92a8e4dc83b0",
                "sha256": "2689134f8c87d051ea37883a1805784ea56372947ffca772d70a4811065cdfbf"
            },
            "downloads": -1,
            "filename": "tempf-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5a7eb5157c4b86ae83bc92a8e4dc83b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 3531,
            "upload_time": "2023-12-01T22:32:06",
            "upload_time_iso_8601": "2023-12-01T22:32:06.649008Z",
            "url": "https://files.pythonhosted.org/packages/5f/66/11df3b2d6d57fdebcb1c2ffbba1455f3b6e5403e3e34e77567c7d299e3e4/tempf-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2936c7932bef0fa4aaea7426e2257b8a2bcbd8b6e5faef20dc0a1a3b5a77f072",
                "md5": "aad2a8be33a6d63da1495f1b2aa077db",
                "sha256": "f3c0bc67b20ab1f5acdb9c4d0d95c82af7475fecebd8dc68a64f0e05bd9fe653"
            },
            "downloads": -1,
            "filename": "tempf-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "aad2a8be33a6d63da1495f1b2aa077db",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 2914,
            "upload_time": "2023-12-01T22:32:08",
            "upload_time_iso_8601": "2023-12-01T22:32:08.547589Z",
            "url": "https://files.pythonhosted.org/packages/29/36/c7932bef0fa4aaea7426e2257b8a2bcbd8b6e5faef20dc0a1a3b5a77f072/tempf-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-01 22:32:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tomhea",
    "github_project": "tempfiles",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tempf"
}
        
Elapsed time: 0.16575s