{ "info": { "author": "Ionel Cristian M\u0103rie\u0219", "author_email": "contact@ionelmc.ro", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Utilities" ], "description": "==========================\n python-pth\n==========================\n\n.. image:: http://img.shields.io/travis/ionelmc/python-pth/master.png\n :alt: Travis-CI Build Status\n :target: https://travis-ci.org/ionelmc/python-pth\n\n.. image:: https://ci.appveyor.com/api/projects/status/49hd684jo3y461oo/branch/master\n :alt: AppVeyor Build Status\n :target: https://ci.appveyor.com/project/ionelmc/python-pth\n\n.. image:: http://img.shields.io/coveralls/ionelmc/python-pth/master.png\n :alt: Coverage Status\n :target: https://coveralls.io/r/ionelmc/python-pth\n\n.. image:: http://img.shields.io/pypi/v/pth.png\n :alt: PYPI Package\n :target: https://pypi.python.org/pypi/pth\n\n.. image:: http://img.shields.io/pypi/dm/pth.png\n :alt: PYPI Package\n :target: https://pypi.python.org/pypi/pth\n\n**Note:** This is in very alpha state.\n\nSimple and brief path traversal and filesystem access library. This library is a bit different that other path manipulation libraries:\n\n* Path are subclasses of strings. You can use them anyhere you would use a string.\n* Almost everything from ``os.path`` is available as a **property** with the same name except:\n\n * ``os.path.relpath`` is a **method**\n * ``os.path.getsize`` becomes a **property** named ``size``\n * ``os.path.getatime`` becomes a **property** named ``atime``\n * ``os.path.getctime`` becomes a **property** named ``ctime``\n * ``os.path.getmtime`` becomes a **property** named ``mtime``\n * ``os.path.split`` becomes a **method** name ``splitpath`` as ``split`` is already a string method\n * ``os.path.join`` becomes a **method** name ``joinpath`` as ``join`` is already a string method\n * ``os.path.commonprefix`` *is not implemented*\n * ``os.path.basename`` becomes a **property** named ``name``\n * ``os.path.dirname`` becomes a **property** named ``dir``\n * ``os.listdir`` becomes a **property** named ``list``\n * ``os.walk`` becomes a **property** named ``tree``\n\n* Calling a *Path* object calls ``open()`` on the path. Takes any argument ``open`` would take (except the filename ofcourse).\n* Transparent support for files in .zip files.\n\nBasically it is designed for extreme brevity. It shares `Unipath `_'s\nstr-subclassing approach and and it has seamless zip support (like Twisted's `ZipPath\n`_).\n\nUsage\n-----\n\nGetting started::\n\n >>> import pth\n >>> pth # the module is a function!\n \n >>> p = pth(\"a.txt\")\n >>> p\n \n >>> p\n \n\n\nAPI\n---\n\n::\n\n >>> p = pth('tests')\n >>> p\n \n\nJoining paths::\n\n >>> p/\"a\"/\"b\"/\"c\"/\"d\"\n \n\n >>> p/\"/root\"\n \n\nProperties::\n\n >>> p.abspath\n \n\n >>> p2 = p/'b.txt'\n >>> p2\n \n\n >>> p.exists\n True\n\n >>> p2.isfile\n True\n\n >>> p2()\n <...'tests/b.txt'...mode...'r'...>\n\n >>> pth('bogus-doesnt-exist')()\n Traceback (most recent call last):\n ...\n pth.PathMustBeFile: [Errno 2] No such file or directory: ...\n\nLooping over children, including files in .zip files::\n\n >>> for i in sorted([i for i in p.tree]): print(i)\n tests/a\n tests/a/a.txt\n tests/b.txt\n tests/test.zip\n tests/test.zip/1\n tests/test.zip/1/1.txt\n tests/test.zip/B.TXT\n tests/test.zip/a.txt\n\n >>> for i in sorted([i for i in p.files]): print(i)\n tests/b.txt\n\n >>> for i in sorted([i for i in p.dirs]): print(i)\n tests/a\n tests/test.zip\n\n >>> for i in sorted([i for i in p.list]): print(i)\n tests/a\n tests/b.txt\n tests/test.zip\n\n >>> list(pth('bogus-doesnt-exist').tree)\n Traceback (most recent call last):\n ...\n pth.PathMustBeDirectory: is not a directory nor a zip !\n\n\nTrying to access inexisting property::\n\n >>> p.bogus\n Traceback (most recent call last):\n ...\n AttributeError: 'Path' object has no attribute 'bogus'\n\nAutomatic wrapping of zips::\n\n >>> p/'test.zip'\n \n\nOther properties::\n\n >>> p.abspath\n \n\n >>> p.abs\n \n\n >>> p.basename\n \n\n >>> p.abs.basename\n \n\n >>> p.name\n \n\n >>> p.dirname\n \n\n >>> p.dir\n \n\n >>> p.exists\n True\n\n >>> pth('~root').expanduser\n \n\n >>> pth('~/stuff').expanduser\n \n\n >>> p.expandvars\n \n\n >>> type(p.atime)\n <... 'float'>\n\n >>> type(p.ctime)\n <... 'float'>\n\n >>> type(p.size)\n <... 'int'>\n\n >>> p.isabs\n False\n\n >>> p.abs.isabs\n True\n\n >>> p.isdir\n True\n\n >>> p.isfile\n False\n\n >>> p.islink\n False\n\n >>> p.ismount\n False\n\n >>> p.lexists\n True\n\n >>> p.normcase\n \n\n >>> p.normpath\n \n\n >>> p.realpath\n \n\n >>> p.splitpath\n (, )\n\n >>> pth('a/b/c/d').splitpath\n (, )\n\n >>> pth('a/b/c/d').parts\n [, , , ]\n\n >>> pth('/a/b/c/d').parts\n [, , , , ]\n\n >>> pth(*pth('/a/b/c/d').parts)\n \n\n >>> p.splitdrive\n ('', )\n\n >>> p.drive\n ''\n\n >>> [i for i in (p/'xxx').tree]\n Traceback (most recent call last):\n ...\n pth.PathMustBeDirectory: is not a directory nor a zip !\n\n >>> (p/'xxx').isfile\n False\n\n >>> (p/'xxx')()\n Traceback (most recent call last):\n ...\n pth.PathMustBeFile: ... 2...\n\n >>> p()\n Traceback (most recent call last):\n ...\n pth.PathMustBeFile: is not a file !\n\n >>> pth('a.txt').splitext\n (, '.txt')\n\n >>> pth('a.txt').ext\n '.txt'\n\n\nZip stuff::\n\n >>> z = pth('tests/test.zip')\n >>> z\n \n\n >>> z.abspath\n \n\n >>> z.abs\n \n\n >>> z.basename # transforms in normal path cauze zip is not accessible in current dir\n \n\n >>> z.abs.basename # transforms in normal path cauze zip is not accessible in current dir\n \n\n >>> import os\n >>> os.chdir('tests')\n >>> z.basename\n \n >>> z.name\n \n >>> os.chdir('..')\n\n >>> z.dirname\n \n\n >>> z.abs.dirname\n \n\n >>> z.dir\n \n\n >>> z.exists\n True\n\n >>> pth('~root').expanduser\n \n\n >>> pth('~/stuff').expanduser\n \n\n >>> z.expandvars\n \n\n >>> type(z.atime)\n Traceback (most recent call last):\n ...\n AttributeError: Not available here.\n\n >>> type(z.ctime)\n <... 'float'>\n\n >>> type(z.size)\n <... 'int'>\n\n >>> z.isabs\n False\n\n >>> z.abs.isabs\n True\n\n >>> z.isdir\n True\n\n >>> z.isfile\n False\n\n >>> z.islink\n False\n\n >>> z.ismount\n False\n\n >>> z.lexists\n Traceback (most recent call last):\n ...\n AttributeError: Not available here.\n\n >>> for i in z.tree: print((str(i), repr(i)))\n ('tests/test.zip/1',...... \"\")\n ('tests/test.zip/1/1.txt', \"\")\n ('tests/test.zip/B.TXT',...\"\")\n ('tests/test.zip/a.txt',...\"\")\n\n >>> for i in z.files: print((str(i), repr(i)))\n ('tests/test.zip/B.TXT',...\"\")\n ('tests/test.zip/a.txt',...\"\")\n\n >>> for i in z.dirs: print((str(i), repr(i)))\n ('tests/test.zip/1',...... \"\")\n\n >>> for i in z.list: print((str(i), repr(i)))\n ('tests/test.zip/1',...... \"\")\n ('tests/test.zip/B.TXT',...\"\")\n ('tests/test.zip/a.txt',...\"\")\n\n >>> (z/'B.TXT')\n \n\n >>> str(z/'B.TXT')\n 'tests/test.zip/B.TXT'\n\n >>> (z/'B.TXT').dirname\n \n\n >>> (z/'B.TXT').rel(z)\n \n\n >>> z.rel(z/'B.TXT')\n \n\n >>> (z/'B.TXT').exists\n True\n\n >>> (z/'B.TXT').normcase\n \n\n >>> (z/'B.TXT').normpath\n \n\n >>> (z/'B.TXT').name\n \n\n >>> (z/'B.TXT').name\n \n\n >>> z.normcase\n \n\n >>> z.normpath\n \n\n >>> z.realpath\n \n\n >>> z.splitpath\n (, )\n\n >>> z.splitdrive\n ('', )\n\n >>> z.drive\n ''\n\n >>> pth('a.txt').splitext\n (, '.txt')\n\n >>> pth('a.txt').ext\n '.txt'\n\nWorking with files in a .zip::\n\n >>> p = z/'B.TXT'\n >>> p.abspath\n \n\n >>> p.abs\n \n\n >>> p.basename\n \n\n >>> p.abs.basename\n \n\n >>> p.name\n \n\n >>> p.dirname\n \n\n >>> p.dir\n \n\n >>> p.exists\n True\n\n >>> type(p.atime)\n Traceback (most recent call last):\n ...\n AttributeError: Not available here.\n\n >>> type(p.ctime)\n <... 'float'>\n\n >>> type(p.size)\n <... 'int'>\n\n >>> p.isabs\n False\n\n >>> p.abs.isabs\n True\n\n >>> p.isdir\n False\n\n >>> p.isfile\n True\n\n >>> p.islink\n False\n\n >>> p.ismount\n False\n\n >>> p.lexists\n Traceback (most recent call last):\n ...\n AttributeError: Not available here.\n\n >>> p.normcase\n \n\n >>> p.normpath\n \n\n >>> p.realpath\n \n\n >>> p.splitpath\n (, )\n\n >>> pth.ZipPath.from_string('tests/test.zip/1/1.txt')\n \n\n >>> p.splitdrive\n ('', )\n\n >>> p.drive\n ''\n\n >>> p.splitext\n (, '.TXT')\n\n >>> p.ext\n '.TXT'\n\n >>> p.joinpath('tete')\n \n\n >>> p.joinpath('tete').exists\n False\n\n >>> p.joinpath('tete').isdir\n False\n\n >>> p.joinpath('tete').isfile\n False\n\n >>> p.joinpath('tete').ctime\n Traceback (most recent call last):\n ...\n pth.PathDoesNotExist: \"There is no item named 'B.TXT/tete' in the archive\"\n\n >>> p.joinpath('tete').size\n Traceback (most recent call last):\n ...\n pth.PathDoesNotExist: \"There is no item named 'B.TXT/tete' in the archive\"\n\n >>> p.relpath('tests')\n \n\n >>> p.joinpath('tete')('rb')\n Traceback (most recent call last):\n ...\n pth.PathMustBeFile: is not a file !\n\n >>> p('r')\n \n\n >>> [i for i in p.tree]\n Traceback (most recent call last):\n ...\n pth.PathMustBeDirectory: is not a directory !\n\n >>> z('rb')\n Traceback (most recent call last):\n ...\n pth.PathMustBeFile: is not a file !\n\nIterating though the contents of the zip::\n\n >>> [i for i in z.tree]\n [, , , ]\n\n >>> [i for i in z.files]\n [, ]\n\n >>> [i for i in z.dirs]\n []\n\nNote that there's this inconsistency with joining absolute paths::\n\n >>> z/pth('/root')\n \n\nVs::\n\n >>> z/'/root'\n \n\nTODO: Make this nicer.\n\n::\n\n >>> pth.ZipPath('tests', '', '')\n \n\n >>> pth.ZipPath.from_string('/bogus/path/to/stuff/bla/bla/bla')\n \n\n >>> pth.ZipPath.from_string('bogus')\n \n\n >>> pth.ZipPath.from_string('tests/test.zip/bogus/path/to/stuff/bla/bla/bla')\n \n\n >>> pth.ZipPath.from_string('tests/1/bogus/path/to/stuff/bla/bla/bla')\n \n\n >>> pth.ZipPath.from_string('tests')\n \n\n >>> pth.ZipPath.from_string('tests/bogus')\n \n\nAnd there's a *temporary path*::\n\n >>> t = pth.TempPath()\n >>> t\n \n\n >>> with t:\n ... with (t/\"booo.txt\")('w+') as f:\n ... _ = f.write(\"test\")\n ... print([i for i in t.tree])\n []\n\n >>> t.exists\n False\n\n\nChangelog\n=========\n\n0.1.0 (2014-06-10)\n-----------------------------------------\n\n* First release on PyPI.", "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/ionelmc/python-pth", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "pth", "package_url": "https://pypi.org/project/pth/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pth/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/ionelmc/python-pth" }, "release_url": "https://pypi.org/project/pth/0.3.0/", "requires_dist": null, "requires_python": null, "summary": "Simple and brief path traversal and filesystem access library.", "version": "0.3.0" }, "last_serial": 1196101, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "6f72cc2e152e4d062693ecb7a7917655", "sha256": "a433ae63a4a3ab94e6e82c120e318f98216c3f0670bdee1525c4e000b971f240" }, "downloads": -1, "filename": "pth-0.0.1.tar.gz", "has_sig": false, "md5_digest": "6f72cc2e152e4d062693ecb7a7917655", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8581, "upload_time": "2013-12-20T19:15:00", "url": "https://files.pythonhosted.org/packages/51/cc/b5d829ab16abaee099a2f54ebaf7025c7be8f1188983193aed9b31f57eb4/pth-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "8ea8d578ac4b5375c78ae4e25b5505d4", "sha256": "a1a0797bcc577f522e8d77212120623cfb56182fabf735daf179b6025cd44de6" }, "downloads": -1, "filename": "pth-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "8ea8d578ac4b5375c78ae4e25b5505d4", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10009, "upload_time": "2014-08-15T21:58:10", "url": "https://files.pythonhosted.org/packages/77/3f/4308c303b38143574dae8f54c63f579164aae1ea408623578599ef94f008/pth-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2ff934c5f7dca20479e18f4c44d871a6", "sha256": "256a19540dfe2171a8cd81e5e6ee9872b3fcf8f9805e117de96ebe14c610db4b" }, "downloads": -1, "filename": "pth-0.1.0.tar.gz", "has_sig": false, "md5_digest": "2ff934c5f7dca20479e18f4c44d871a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16194, "upload_time": "2014-08-15T21:58:07", "url": "https://files.pythonhosted.org/packages/e0/8d/7d355e5ed37a151b21d0377a663ba2ad0fb298ca6f1263379c35ff2036f9/pth-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "43ac9f3710c267a390df996851d05827", "sha256": "88c76785448279c911afbf90d65548695e6fee566a340d83f29a9e2ac3f960ab" }, "downloads": -1, "filename": "pth-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "43ac9f3710c267a390df996851d05827", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9840, "upload_time": "2014-08-15T22:02:10", "url": "https://files.pythonhosted.org/packages/2d/3f/8c5400f2d5e797123481de701a20d10d67fdda02dc2f10a1135e2bf8eb45/pth-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af14a6ef864cc3992832c013ad1c9721", "sha256": "3ee9f7e56f7d2ccd47125f863f320f36b1d1cf924f90433b1fb504ac7894d7b5" }, "downloads": -1, "filename": "pth-0.1.1.tar.gz", "has_sig": false, "md5_digest": "af14a6ef864cc3992832c013ad1c9721", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16028, "upload_time": "2014-08-15T22:02:07", "url": "https://files.pythonhosted.org/packages/61/8b/d5a3bf15401b6ccf59ed113fcbdcb7e33b1e39cf739037053172568b0a65/pth-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "b2395278ff7cf294491d8af60b243b13", "sha256": "46079a00718c4fb184170cab1d9f6bd2f88ee1c5e8ad15465750e518264f5392" }, "downloads": -1, "filename": "pth-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b2395278ff7cf294491d8af60b243b13", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 9992, "upload_time": "2014-08-18T16:26:40", "url": "https://files.pythonhosted.org/packages/e2/ab/8ed5e3be17c4fd13d97320802ff8bbf49d1da0880c7bcc9ee5be527e97e0/pth-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d0d8ada9b2dbe2e6b9d94f52c0c76339", "sha256": "a97a29b5034c39dc44278eed976e13f42dc69340c83cc0701e6210705cd75382" }, "downloads": -1, "filename": "pth-0.2.0.tar.gz", "has_sig": false, "md5_digest": "d0d8ada9b2dbe2e6b9d94f52c0c76339", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16372, "upload_time": "2014-08-18T16:26:38", "url": "https://files.pythonhosted.org/packages/d0/96/5f17bb4b43b66f9bde6fc5d03afbc53dedbccc8acb1550c64eb8aff089d7/pth-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "9c00d19f1ae7fa2c5c352b08b81d11b2", "sha256": "1c7f7b1456ec8a97ac2ea71b1f1ceb7d35fcdcd07c8845fda5585b8fb157aa97" }, "downloads": -1, "filename": "pth-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9c00d19f1ae7fa2c5c352b08b81d11b2", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10290, "upload_time": "2014-08-20T02:00:24", "url": "https://files.pythonhosted.org/packages/88/0a/0c01ca43eace546a12bc2fd2ab95588c1a87c3fec853d169ff57c1a60168/pth-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02e3cfe0e74f06292cf9729c4de30f78", "sha256": "206e5f104d8f4949b66c6f418d30e585546ef8cdd08428a556ddc43f25c07cd4" }, "downloads": -1, "filename": "pth-0.3.0.tar.gz", "has_sig": false, "md5_digest": "02e3cfe0e74f06292cf9729c4de30f78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16730, "upload_time": "2014-08-20T02:00:21", "url": "https://files.pythonhosted.org/packages/6f/68/31fda6cb2092373ce5ba460139b0ee37814411927e3a6f5e9847679b6ef7/pth-0.3.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9c00d19f1ae7fa2c5c352b08b81d11b2", "sha256": "1c7f7b1456ec8a97ac2ea71b1f1ceb7d35fcdcd07c8845fda5585b8fb157aa97" }, "downloads": -1, "filename": "pth-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9c00d19f1ae7fa2c5c352b08b81d11b2", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10290, "upload_time": "2014-08-20T02:00:24", "url": "https://files.pythonhosted.org/packages/88/0a/0c01ca43eace546a12bc2fd2ab95588c1a87c3fec853d169ff57c1a60168/pth-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02e3cfe0e74f06292cf9729c4de30f78", "sha256": "206e5f104d8f4949b66c6f418d30e585546ef8cdd08428a556ddc43f25c07cd4" }, "downloads": -1, "filename": "pth-0.3.0.tar.gz", "has_sig": false, "md5_digest": "02e3cfe0e74f06292cf9729c4de30f78", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16730, "upload_time": "2014-08-20T02:00:21", "url": "https://files.pythonhosted.org/packages/6f/68/31fda6cb2092373ce5ba460139b0ee37814411927e3a6f5e9847679b6ef7/pth-0.3.0.tar.gz" } ] }