Skip to main content

Simple module for easily isolating temporary file I/O

Project description

Latest Version Travis-ci build status

A simple module for easily isolating temporary file I/O to a directory. Ever developed a command-line tool which required a lot of file manipulation? Caching, perhaps? You don’t want to use the cwd and keeping all of your paths straight if you’re working outside of it can be a pain. This tool may be the pain-reliever you need!

A tale of sin and woe

Well, not really. I’ve just developed a bunch of tools that rely on various bits of temporary or isolated file I/O, and found myself implementing this pattern over and over again. Eventually, I got tired of doing it and decided to develop this handy module. Now I’m passing the savings on to you!

Compatibility

As far as I know, workdir is compatible with every version of Python from 2.6 through 3.5. It should also be compatible with all major platforms including Linux, OSX, and Windows. If not, let me know!

Installation

pip install workdir

Examples

Use it as a staging area for downloaded archives:

import workdir
import shutil
workdir.options.path = '~/.myfilecache'
with workdir.as_cwd():
    download_remote_archive('somefile')
    unpack_archive('somefile', 'somedir')
shutil.copy(workdir.path_to_file('somedir', 'unpackedfilefromarchive'),
            os.path.join('otherdir', 'unpackedfilefromarchive'))

Use it as a working directory in your git repo (added to .gitignore, of course):

import workdir
workdir.options.path = '.gitrepo.work'
workdir.sync()
with workdir.as_cwd():
    futz_with_source_tree()
    more_futzing()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

workdir-0.3.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

workdir-0.3.2-py2.py3-none-any.whl (3.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file workdir-0.3.2.tar.gz.

File metadata

  • Download URL: workdir-0.3.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for workdir-0.3.2.tar.gz
Algorithm Hash digest
SHA256 8be0d0fb22e922ac4d6a394defb00bee9e9302db596fc7ea65ec53342d0fc947
MD5 8a4ab1110cba3932a631359a9abec55d
BLAKE2b-256 2d91c981b7c190643f0db9d7988bfe75f4de55436e9b7b6de55b8105f6f829c5

See more details on using hashes here.

File details

Details for the file workdir-0.3.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for workdir-0.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bfb0f0b0781bbab13a884d456047a137700f4c704a1c3112ab7e5a3c8830f77b
MD5 11595bf69d439cb125f0173fbb57fc0c
BLAKE2b-256 0e17d74173d1c5afdc5ed61bd8f7b2d0637568462afba099c8a4c5b1f4a9dd66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page