{ "info": { "author": "Lutz Prechelt", "author_email": "prechelt@inf.fu-berlin.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Two decorators ``add_unread`` and ``add_unnext``\nfor file-like objects and iterators, respectively.\n``add_unread`` introduces a function ``unread()`` for pushing data\nobtained by ``read()`` or ``readline()`` back into the input stream.\n``add_unnext`` introduces a function ``unnext()`` for pushing an item\nback into an iterator (to be returned by the next ``__next__()``)\n\n``add_unread`` will work for all kinds of streams:\nmemory-based or file-based, binary or text,\nbuffered or unbuffered.\nIt will also work with higher level operations\nif those are properly built on top of ``read()`` or ``readline()``\nand also allows to insert content not previously read, because\nthe actual stream is never modified (only a pushback buffer added).\n\n::\n\n import io\n from unread_decorator import add_unread\n\n f = io.StringIO(\"one\\ntwo\\nthree\") # or: f = open(\"myfile.txt\")\n f = add_unread(f) # decorate\n data = f.readline() # 'one\\n'\n data = f.readline() # 'two\\n'\n f.unread(data)\n data = f.readline() # 'two\\n'\n f.unread(data)\n f.unread(\"more than \")\n print(f.read()) # prints \"more than two\\nthree\"\n\n\n``add_unnext`` will work for all kinds of iterators as well as\niterables.\nIt is useful if you want to forward some part of an interation to\na separate function based on what you encountered.\nIt also allows to insert content not previously received from the iterator.\n\n::\n\n from unread_decorator import add_unnext\n\n items = add_unnext([11, 12, 13])\n results = []\n for item in items:\n results.append(item)\n if len(results) == 2:\n items.unnext(item)\n items.unnext(77)\n assert results == [11, 12, 77, 12, 13]\n\n\nFind the documentation at\nhttps://github.com/prechelt/unread-decorator", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/prechelt/unread-decorator", "keywords": "undo,I/O,iterator", "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "unread-decorator", "package_url": "https://pypi.org/project/unread-decorator/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/unread-decorator/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/prechelt/unread-decorator" }, "release_url": "https://pypi.org/project/unread-decorator/1.0/", "requires_dist": null, "requires_python": null, "summary": "unread() for streams, unnext() for iterators", "version": "1.0" }, "last_serial": 1337164, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "c96109511116c4ad049d7331c9d314ca", "sha256": "7ab04b65879667aaf7213b208692fbc5a268ac52bdec35a3f24e68fef3dd04a7" }, "downloads": -1, "filename": "unread-decorator-1.0.zip", "has_sig": false, "md5_digest": "c96109511116c4ad049d7331c9d314ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7356, "upload_time": "2014-12-09T14:44:38", "url": "https://files.pythonhosted.org/packages/4e/86/28aa947985602ad7340023bae7ccbd91303a8424f53a49068ae4fce104f2/unread-decorator-1.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c96109511116c4ad049d7331c9d314ca", "sha256": "7ab04b65879667aaf7213b208692fbc5a268ac52bdec35a3f24e68fef3dd04a7" }, "downloads": -1, "filename": "unread-decorator-1.0.zip", "has_sig": false, "md5_digest": "c96109511116c4ad049d7331c9d314ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7356, "upload_time": "2014-12-09T14:44:38", "url": "https://files.pythonhosted.org/packages/4e/86/28aa947985602ad7340023bae7ccbd91303a8424f53a49068ae4fce104f2/unread-decorator-1.0.zip" } ] }