{ "info": { "author": "Todd Francis DeLuca", "author_email": "todddeluca@yahoo.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7" ], "description": "## Introduction\n\n`temps` is a python module containing context managers for creating and\ncleaning up temporary files and directories.\n\nThis package is _alpha_ and its API is not stable.\n\nWhy do I never use the `tempfile` module?\n\n- I am responsible for removing files and dirs tempfile creates, which creates\n lots of boilerplate whenever I use it.\n- There is no context manager for temp dirs.\n- When using `mkstemp()`, I get an open file descriptor, not a file object,\n that I have to close.\n- The context manager for temp files contains statements like this\n from the tempfile docs: \"Whether the name can be used to open the file a\n second time, while the named temporary file is still open, varies across\n platforms\"\n- I do not get to choose the file perms of files and dirs I create.\n\nWhat do I like about this module?\n\n- It has a context manager for creating a temp dir and another for temp files.\n- The context manager cleans up the dir or file upon context exit, not upon file\n closure.\n- No ambiguity about whether you can or cannot open a file twice.\n- You can set the permissions of the temp file or dir to what you want.\n- It is very clear what the implementation is:\n - directories are created and the path is returned.\n - files are not created, since you'll want to do that in a `with\n open(filename) ...` statement, and the path is returned.\n - directories and files are cleaned up by the context managers.\n - file and dir names are generated using the uuid module, which presumably\n will avoid race conditions.\n\n\n## Contribute\n\nFeel free to make a pull request on github.\n\n\n## Requirements\n\n- Probably Python 2.7 (since that is the only version it has been tested with.)\n\n\n## Installation\n\n\n### Install from pypi.python.org\n\nDownload and install using pip:\n\n pip install temps\n\n\n### Install from github.com\n\nUsing github, one can clone and install a specific version of the package:\n\n cd ~\n git clone git@github.com:todddeluca/temps.git\n cd temps\n python setup.py install\n\n\n## Usage\n\nCreating a working dir for subprocesses:\n\n with temps.tmpdir() as workdir:\n with open(os.path.join(workdir, 'datafile'), 'wb') as fh:\n fh.write(data)\n subprocess.call('compute.sh {}'.format(workdir), shell=True)\n with open(os.path.join(workdir, 'outfile')) as fh:\n print fh.read()\n\nCreating a temp file for a transform and upload:\n\n with temps.tmpfile() as transformed_path:\n transform(input_path, transformed_path)\n upload(transformed_path, destination)\n\nThe default values when parameters are not specified, are stored in variables\nthat are set using environment variables if available or a default value\notherwise. Here is a table listing the variable, the environment variable \nchecked, and the default value:\n\n Variable, ENV_VAR, Default\n TEMPS_DIR, TEMPS_DIR, tempfile.gettempdir()\n TEMPS_PREFIX, TEMPS_PREFIX, ''\n TEMPS_SUFFIX, TEMPS_SUFFIX, ''\n TEMPS_MODE, TEMPS_MODE, '0777'", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/todddeluca/temps", "keywords": "python temporary files directories context manager", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "temps", "package_url": "https://pypi.org/project/temps/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/temps/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/todddeluca/temps" }, "release_url": "https://pypi.org/project/temps/0.3.0/", "requires_dist": null, "requires_python": null, "summary": "Context managers for creating and cleaning up temporary directories and files.", "version": "0.3.0" }, "last_serial": 1237145, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "8eefd85603455867135a56265f5a2f6f", "sha256": "a827edfd119a63ecd85b3ae77f57ea853f4e0d1cac10939504f2ab72c3f5e9c2" }, "downloads": -1, "filename": "temps-0.1.tar.gz", "has_sig": false, "md5_digest": "8eefd85603455867135a56265f5a2f6f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4179, "upload_time": "2012-10-29T07:27:42", "url": "https://files.pythonhosted.org/packages/c9/00/272ee656365e693c45e64410a15b74accc2a739148c57735f98bbec7c392/temps-0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "641befa53104fc21a9c42d85d2e76be4", "sha256": "25c4fea8f401159498445b078a28b206df07e8d2ebad3f2cd22d06bb6d562df1" }, "downloads": -1, "filename": "temps-0.1.0.tar.gz", "has_sig": false, "md5_digest": "641befa53104fc21a9c42d85d2e76be4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4193, "upload_time": "2013-02-13T21:24:57", "url": "https://files.pythonhosted.org/packages/95/dd/6acef56679c3e6fa00c8a6a48f2e894036404a768c3643090e887332d7d1/temps-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "1ce82973a08d08c4ee4ea0825011fa1a", "sha256": "bfff9be505964c0e838958431fd4bf0d00af95d75ca57b5b2066db45e47a5ebc" }, "downloads": -1, "filename": "temps-0.2.0.tar.gz", "has_sig": false, "md5_digest": "1ce82973a08d08c4ee4ea0825011fa1a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4250, "upload_time": "2013-03-01T21:27:48", "url": "https://files.pythonhosted.org/packages/fb/25/b276e9e2974953381275dcf081c6c0f2fe9b59743188ecd79e9f05ef39a4/temps-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "6c308a70ddc1c36023a1571243325bc3", "sha256": "bc2b1489e4b118e5d0d174f841b487dea3f46dacc0da6c0814064f63f86c150d" }, "downloads": -1, "filename": "temps-0.3.0.tar.gz", "has_sig": false, "md5_digest": "6c308a70ddc1c36023a1571243325bc3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4773, "upload_time": "2014-09-25T02:22:49", "url": "https://files.pythonhosted.org/packages/4d/a5/1ce68a8088f9373566655c205910966da8222fd0e7f68bddd8ce5a28786e/temps-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6c308a70ddc1c36023a1571243325bc3", "sha256": "bc2b1489e4b118e5d0d174f841b487dea3f46dacc0da6c0814064f63f86c150d" }, "downloads": -1, "filename": "temps-0.3.0.tar.gz", "has_sig": false, "md5_digest": "6c308a70ddc1c36023a1571243325bc3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4773, "upload_time": "2014-09-25T02:22:49", "url": "https://files.pythonhosted.org/packages/4d/a5/1ce68a8088f9373566655c205910966da8222fd0e7f68bddd8ce5a28786e/temps-0.3.0.tar.gz" } ] }