volatile-2.1.0
توضیحات
A small extension for the tempfile module.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | volatile-2.1.0 |
| نام | volatile |
| نسخه کتابخانه | 2.1.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Marc Brinkmann |
| ایمیل نویسنده | git@marcbrinkmann.de |
| آدرس صفحه اصلی | https://github.com/mbr/volatile |
| آدرس اینترنتی | https://pypi.org/project/volatile/ |
| مجوز | MIT |
volatile
========
Temporary files and directories.
Contains replacement for ``tempfile.NamedTemporaryFile`` that does not delete
the file on ``close()``, but still unlinks it after the context manager ends,
as well as a ``mkdtemp``-based temporary directory implementation.
* Mostly reuses the stdlib implementations, supporting the same signatures.
* Due to that, uses the OS's built-in temporary file facilities, no custom
schemes.
* Tested on Python 2.6+ and 3.3+
Usage
-----
A typical use-case that is not possible with the regular
``NamedTemporaryFile``:
.. code-block:: python
import volatile
with volatile.file() as tmp:
# tmp behaves like a regular NamedTemporaryFile here, except for that
# it gets unlinked at the end of the context manager, instead of when
# close() is called.
tmp.close()
# run the users $EDITOR
run_editor(tmp.name)
buf = open(tmp.name).read()
# ...
Temporary directories:
.. code-block:: python
import volatile
with volatile.dir(): as dtmp:
pass # ... can use directory here
# a missing dtmp will not throw an exception!
Unix domain sockets:
.. code-block:: python
import volatile
with volatile.unix_socket(): as (sock, addr):
# sock is the bound socket, addr its address on the filesystem
pass # ... can use directory here
The source is fairly short and contains `API docs in the comments
<https://github.com/mbr/volatile/blob/master/volatile/__init__.py>`_.
نحوه نصب
نصب پکیج whl volatile-2.1.0:
pip install volatile-2.1.0.whl
نصب پکیج tar.gz volatile-2.1.0:
pip install volatile-2.1.0.tar.gz