{ "info": { "author": "Marko Ristin", "author_email": "marko@parquery.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5" ], "description": "temppathlib\n===========\n\ntemppathlib provides wrappers around ``tempfile`` so that you can directly use them together with ``pathlib`` module.\nWe found it cumbersome to convert ``tempfile`` objects manually to ``pathlib.Path`` whenever we needed a temporary\nfile.\n\nAdditionally, we also provide:\n\n* a context manager ``removing_tree`` that checks if a path exists and recursively deletes it\n by wrapping ``shutil.rmtree``.\n\n* a context manager ``TmpDirIfNecessary`` that creates a temporary directory if no directory is given and otherwise\n uses a supplied directory. This is useful when you want to keep some of the temporary files for examination\n after the program finished. We usually specify an optional ``--operation_dir`` command-line argument to our programs\n and pass its value to the ``TmpDirIfNecessary``.\n\nIf you need a more complex library to transition from string paths to ``pathlib.Path``, have a look at\nruamel.std.pathlib_.\n\n.. _ruamel.std.pathlib: https://pypi.org/project/ruamel.std.pathlib/\n\nUsage\n=====\n.. code-block:: python\n\n import pathlib\n\n import temppathlib\n\n # create a temporary directory\n with temppathlib.TemporaryDirectory() as tmp_dir:\n tmp_pth = tmp_dir.path / \"some-filename.txt\"\n # do something else with tmp_dir ...\n\n # create a temporary file\n with temppathlib.NamedTemporaryFile() as tmp:\n # write to it\n tmp.file.write('hello'.encode())\n tmp.file.flush()\n\n # you can use its path.\n target_pth = pathlib.Path('/some/permanent/directory') / tmp.path.name\n\n # create a temporary directory only if necessary\n operation_dir = pathlib.Path(\"/some/operation/directory)\n with temppathlib.TmpDirIfNecessary(path=operation_dir) as op_dir:\n # do something with the operation directory\n pth = op_dir.path / \"some-file.txt\"\n\n # operation_dir is not deleted since 'path' was specified.\n\n\n with temppathlib.TmpDirIfNecessary() as op_dir:\n # do something with the operation directory\n pth = op_dir.path / \"some-file.txt\"\n\n # op_dir is deleted since 'path' argument was not specified.\n\n # context manager to remove the path recursively\n pth = pathlib.Path('/some/directory')\n with temppathlib.removing_tree(pth):\n # do something in the directory ...\n pass\n\nInstallation\n============\n\n* Create a virtual environment:\n\n.. code-block:: bash\n\n python3 -m venv venv3\n\n* Activate it:\n\n.. code-block:: bash\n\n source venv3/bin/activate\n\n* Install temppathlib with pip:\n\n.. code-block:: bash\n\n pip3 install temppathlib\n\nDevelopment\n===========\n\n* Check out the repository.\n\n* In the repository root, create the virtual environment:\n\n.. code-block:: bash\n\n python3 -m venv venv3\n\n* Activate the virtual environment:\n\n.. code-block:: bash\n\n source venv3/bin/activate\n\n* Install the development dependencies:\n\n.. code-block:: bash\n\n pip3 install -e .[dev]\n\n* We use tox for testing and packaging the distribution. Assuming that the virtual environment has been activated and\n the development dependencies have been installed, run:\n\n.. code-block:: bash\n\n tox\n\n* We also provide a set of pre-commit checks that lint and check code for formatting. Run them locally from an activated\n virtual environment with development dependencies:\n\n.. code-block:: bash\n\n ./precommit.py\n\n* The pre-commit script can also automatically format the code:\n\n.. code-block:: bash\n\n ./precommit.py --overwrite\n\nVersioning\n==========\nWe follow `Semantic Versioning `_. The version X.Y.Z indicates:\n\n* X is the major version (backward-incompatible),\n* Y is the minor version (backward-compatible), and\n* Z is the patch version (backward-compatible bug fix).", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Parquery/temppathlib", "keywords": "tempfile pathlib temporary file directory mkdtemp mkstemp", "license": "", "maintainer": "", "maintainer_email": "", "name": "temppathlib", "package_url": "https://pypi.org/project/temppathlib/", "platform": "", "project_url": "https://pypi.org/project/temppathlib/", "project_urls": { "Homepage": "https://github.com/Parquery/temppathlib" }, "release_url": "https://pypi.org/project/temppathlib/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "Wraps tempfile to give you pathlib.Path.", "version": "1.0.3" }, "last_serial": 5410395, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "26c990f904a97ce28006aaf292a03393", "sha256": "95b172534bd8af2e983d607b94a780a424f181d1cd6aab4324a46683531e9c11" }, "downloads": -1, "filename": "temppathlib-1.0.0.tar.gz", "has_sig": false, "md5_digest": "26c990f904a97ce28006aaf292a03393", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4683, "upload_time": "2018-05-03T07:15:01", "url": "https://files.pythonhosted.org/packages/73/59/d4657f0d164764799e06e175934187f3aef172d415760a6b585d53d0731c/temppathlib-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "8bb56c9d963d7c312e5542258e99217a", "sha256": "eb63a87c3af74939ea9eaf4951efa45f19c3f48ff94d3e2a6e4204042cfeee49" }, "downloads": -1, "filename": "temppathlib-1.0.1.tar.gz", "has_sig": false, "md5_digest": "8bb56c9d963d7c312e5542258e99217a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4705, "upload_time": "2018-06-14T05:08:42", "url": "https://files.pythonhosted.org/packages/45/5e/8d3bb62bf803bd744949711100160d565a276ad592a0eacfc029ff0c1805/temppathlib-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "417ab6e06106827613f05d237f36525b", "sha256": "e192cb6cd900781584d1e1a3467a40b5fe69df33be3b17795553e1ecb69a0193" }, "downloads": -1, "filename": "temppathlib-1.0.2.tar.gz", "has_sig": false, "md5_digest": "417ab6e06106827613f05d237f36525b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4788, "upload_time": "2018-08-03T12:40:51", "url": "https://files.pythonhosted.org/packages/e8/0f/5f7c4ef618b6bba67de132ef06ab57fcb2f7cdce3e3192f91430eee0ba42/temppathlib-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "333a80a1074d9738cb7b9ba965b8fe61", "sha256": "58eaea9190639591f5005289e128b3b822eb5a3341d538ffdb7e67a73526421a" }, "downloads": -1, "filename": "temppathlib-1.0.3.tar.gz", "has_sig": false, "md5_digest": "333a80a1074d9738cb7b9ba965b8fe61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4842, "upload_time": "2018-08-03T13:20:40", "url": "https://files.pythonhosted.org/packages/93/93/c08ef671b550c57c2bd57e173795e6669221af847bd3b29702e3df427615/temppathlib-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "333a80a1074d9738cb7b9ba965b8fe61", "sha256": "58eaea9190639591f5005289e128b3b822eb5a3341d538ffdb7e67a73526421a" }, "downloads": -1, "filename": "temppathlib-1.0.3.tar.gz", "has_sig": false, "md5_digest": "333a80a1074d9738cb7b9ba965b8fe61", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4842, "upload_time": "2018-08-03T13:20:40", "url": "https://files.pythonhosted.org/packages/93/93/c08ef671b550c57c2bd57e173795e6669221af847bd3b29702e3df427615/temppathlib-1.0.3.tar.gz" } ] }