{ "info": { "author": "Ross Patterson", "author_email": "me@rpatterson.net", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": ".. -*-doctest-*-\n\n===================\nrpatterson.listfile\n===================\n\nSupport list operations over lines of file-like objects.\n\nAll operations avoid iterating except when necessary. Operations that\nforce iteration over the whole file include len() and using negative\nindexes. In order to avoid excess seeking, all list operations may\nchange the position of the underlying file object.\n\nStart with a file-like object.\n\n >>> import cStringIO\n >>> file_ = cStringIO.StringIO(\"\"\"\\\n ... foo\n ... bar\n ... baz\n ... qux\n ... \"\"\")\n\nWrap the file-like object in a listfile instance.\n\n >>> from rpatterson import listfile\n >>> wrapped = listfile.ListFile(file_)\n\nLines can be accessed by index.\n\n >>> wrapped[0]\n 'foo\\n'\n >>> wrapped[2]\n 'baz\\n'\n\nNegative indexes are supported as well.\n\n >>> wrapped[-1]\n 'qux\\n'\n >>> wrapped[-3]\n 'bar\\n'\n\nThe length returns the number of lines.\n\n >>> len(wrapped)\n 4\n\nAn index beyond the end of the file raises IndexError.\n\n >>> wrapped[4]\n Traceback (most recent call last):\n IndexError: list index out of range\n\nRetrieving a slice returns a new wrapper around the same file object.\n\n >>> slice_ = wrapped[1:3]\n >>> len(slice_)\n 2\n >>> slice_[0]\n 'bar\\n'\n >>> slice_[1]\n 'baz\\n'\n\n >>> slice_ = wrapped[1:][0:2]\n >>> len(slice_)\n 2\n >>> slice_[0]\n 'bar\\n'\n >>> slice_[1]\n 'baz\\n'\n\nSlice stepping is also supported.\n\n >>> slice_ = wrapped[1::2]\n >>> len(slice_)\n 2\n >>> slice_[0]\n 'bar\\n'\n >>> slice_[1]\n 'qux\\n'\n\nThe wrappers are also iterators suitable for writelines().\n\n >>> list(slice_)\n ['bar\\n', 'qux\\n']\n >>> out = cStringIO.StringIO()\n >>> out.writelines(slice_)\n >>> out.getvalue()\n 'bar\\nqux\\n'\n\n\nChangelog\n=========\n\n0.1 - 2009-05-27\n----------------\n\n* Initial release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/rpatterson.listfile", "keywords": "", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "rpatterson.listfile", "package_url": "https://pypi.org/project/rpatterson.listfile/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/rpatterson.listfile/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/rpatterson.listfile" }, "release_url": "https://pypi.org/project/rpatterson.listfile/0.1/", "requires_dist": null, "requires_python": null, "summary": "Support list operations over lines of file-like objects", "version": "0.1" }, "last_serial": 799056, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "9e97ce01fb72c8a65d497fb233a9ccaa", "sha256": "5046b89f9a73c080289696a0f2dcf31897ce10f2cbe0a867f4f38a84e24cf1bb" }, "downloads": -1, "filename": "rpatterson.listfile-0.1.tar.gz", "has_sig": false, "md5_digest": "9e97ce01fb72c8a65d497fb233a9ccaa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4369, "upload_time": "2009-05-28T02:03:47", "url": "https://files.pythonhosted.org/packages/7e/b3/3b3c0e28c024a1f4379205bf81aa433c2a4f41d943a50f866da5960b8b32/rpatterson.listfile-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9e97ce01fb72c8a65d497fb233a9ccaa", "sha256": "5046b89f9a73c080289696a0f2dcf31897ce10f2cbe0a867f4f38a84e24cf1bb" }, "downloads": -1, "filename": "rpatterson.listfile-0.1.tar.gz", "has_sig": false, "md5_digest": "9e97ce01fb72c8a65d497fb233a9ccaa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4369, "upload_time": "2009-05-28T02:03:47", "url": "https://files.pythonhosted.org/packages/7e/b3/3b3c0e28c024a1f4379205bf81aa433c2a4f41d943a50f866da5960b8b32/rpatterson.listfile-0.1.tar.gz" } ] }