https://github.com/aleskrejcicz/sptempdir
This module generates temporary directories.
https://github.com/aleskrejcicz/sptempdir
python sptempdir temp tempdir temporary-directory
Last synced: 5 months ago
JSON representation
This module generates temporary directories.
- Host: GitHub
- URL: https://github.com/aleskrejcicz/sptempdir
- Owner: aleskrejcicz
- Created: 2015-07-11T17:09:25.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-04-19T13:26:24.000Z (about 9 years ago)
- Last Synced: 2025-11-27T21:42:31.441Z (6 months ago)
- Topics: python, sptempdir, temp, tempdir, temporary-directory
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# (SP)TEMPDIR
**Function parameters:**
sptempdir.TemporaryDirectory(suffix="", prefix="", dir=None, delete=True)
By default temporary directory will be deleted when function it is closed.
### Example 1:
The `name` property returns the name of a temporary directory.
```python
import os
from sptempdir import TemporaryDirectory
with TemporaryDirectory(prefix="prefbegin_", suffix="_suffend") as temp:
print('temp.name:', temp.name) # retrieve the name temporary directory
print('Inside:', os.path.exists(temp.name))
print('Outside:', os.path.exists(temp.name))
```
*Terminal output:*
$ temporary_directory.py
temp.name: /tmp/prefbegin_66XxiFkN6Nm4_suffend
Inside: True
Outside: False
### Example 2:
```python
import os
from sptempdir import TemporaryDirectory
temp = TemporaryDirectory()
print('temp.name:', temp.name) # retrieve the name temporary directory
print('Tempdir exists:', os.path.exists(temp.name))
temp.remove() # manually remove temporary directory
print('Tempdir exists:', os.path.exists(temp.name))
```
*Terminal output:*
$ temporary_directory.py
temp.name: /tmp/RCgAzfsATQnb
Tempdir exists: True
Tempdir exists: False
### Example 3:
If the delete parameter is `delete=False`, the temp directory is not deleted.
```python
import os
from sptempdir import TemporaryDirectory
temp = TemporaryDirectory(delete=False)
print('temp.name:', temp.name) # retrieve the name temporary directory
print('Tempdir exists:', os.path.exists(temp.name))
temp.remove() # manually remove temporary directory
print('Tempdir exists:', os.path.exists(temp.name))
```
*Terminal output:*
$ temporary_directory.py
temp.name: /tmp/kWwCWn42NRsr
Tempdir exists: True
Tempdir exists: False
### Example 4:
Specific `dir` where you want to create temporary directory.
```python
from sptempdir import TemporaryDirectory
temp = TemporaryDirectory(dir="/home/user/Desktop")
print(temp.name) # retrieve the name temporary directory
```
*Terminal output:*
$ temporary_directory.py
/home/user/Desktop/4ZdTvLNqVuyE
### Installation:
pip install sptempdir
### License:
BSD
-----------------------
(SP)TEMPDIR = **( S**imple **P**ython **)** **TEMPDIR**
-----------------------
[](https://github.com/aleskrejcicz/sptempdir) [](https://pypi.python.org/pypi/sptempdir) [](https://pypi.python.org/pypi/sptempdir) [](https://pypi.python.org/pypi/sptempdir)