tempdirs -- Safely create temporary directories
Project description
Description
tempdirs is a library which allows users to safely and cleanly create any number of temporary directories. Temporary directories are automatically deleted. It was created as a testing utility.
Installation
Install using pip:
pip install pyusps
or easy_install:
easy_install pyusps
Examples
You can tempdirs.makedirs as a decorator passing in the number of temporary directories needed:
import os import tempdirs @tempdirs.makedirs(2) def test_foo(srcdir, dstdir): srcfile = os.path.join(srcdir,'foo') dstfile = os.path.join(dstdir,'bar') with open(srcfile, 'w') as fp: fp.write('src content\n') with open(dstfile, 'w') as fp: fp.write('dst content\n')
You can also use tempdirs.makedirs as a Context Manager:
import os import tempdirs with tempdirs.makedirs(2) as (srcdir, dstdir): srcfile = os.path.join(srcdir,'foo') dstfile = os.path.join(dstdir,'bar') with open(srcfile, 'w') as fp: fp.write('src content\n') with open(dstfile, 'w') as fp: fp.write('dst content\n')
Developing
External dependencies
python-dev
python-setuptools
python-virtualenv
Setup
To start developing run the following commands from the project’s base directory. You can download the source from https://github.com/thelinuxkid/tempdirs:
# I like to install the virtual environment in its own # hidden repo but you don't have to virtualenv .virtual # I leave the magic to Ruby developers (.virtual/bin/activate) # but you don't have to agree with me .virtual/bin/python setup.py develop # Install the testing dependecies. Pip doesn't seem to handle # extras_require yet: https://github.com/pypa/pip/issues/7. # So, use easy_install. # At this point, tempdirs will already be in easy-install.pth. # So easy_install will not attempt to download it .virtual/bin/easy_install tempdirs[test]
If you like to use ipython you can install it with the dev requirement:
.virtual/bin/easy_install tempdirs[dev]
Testing
To run the unit-tests run the following command from the project’s base directory:
.virtual/bin/nosetests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.