{ "info": { "author": "Tin Tvrtkovic", "author_email": "tinchester@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: System :: Filesystems" ], "description": "aiofiles: file support for asyncio\n==================================\n\n.. image:: https://img.shields.io/pypi/v/aiofiles.svg\n :target: https://pypi.python.org/pypi/aiofiles\n.. image:: https://travis-ci.org/Tinche/aiofiles.svg?branch=master\n :target: https://travis-ci.org/Tinche/aiofiles\n.. image:: https://coveralls.io/repos/Tinche/aiofiles/badge.svg?branch=master\n :target: https://coveralls.io/r/Tinche/aiofiles?branch=master\n\naiofiles is an Apache2 licensed library, written in Python, for handling local\ndisk files in asyncio applications.\n\nOrdinary local file IO is blocking, and cannot easily and portably made\nasynchronous. This means doing file IO may interfere with asyncio applications,\nwhich shouldn't block the executing thread. aiofiles helps with this by\nintroducing asynchronous versions of files that support delegating operations to\na separate thread pool.\n\n.. code-block:: python\n\n async with aiofiles.open('filename', mode='r') as f:\n contents = await f.read()\n print(contents)\n 'My file contents'\n\nOr, using the old syntax:\n\n.. code-block:: python\n\n f = yield from aiofiles.open('filename', mode='r')\n try:\n contents = yield from f.read()\n finally:\n yield from f.close()\n print(contents)\n 'My file contents'\n\nFeatures\n--------\n\n- a file API very similar to Python's standard, blocking API\n- support for buffered and unbuffered binary files, and buffered text files\n- support for async/await (PEP 492) constructs\n\n\nInstallation\n------------\n\nTo install aiofiles, simply:\n\n.. code-block:: bash\n\n $ pip install aiofiles\n\nUsage\n-----\n\nFiles are opened using the ``aiofiles.open()`` coroutine, which in addition to\nmirroring the builtin ``open`` accepts optional ``loop`` and ``executor``\narguments. If ``loop`` is absent, the default loop will be used, as per the\nset asyncio policy. If ``executor`` is not specified, the default event loop\nexecutor will be used.\n\nIn case of success, an asynchronous file object is returned with an\nAPI identical to an ordinary file, except the following methods are coroutines\nand delegate to an executor:\n\n* ``close``\n* ``flush``\n* ``isatty``\n* ``read``\n* ``readall``\n* ``read1``\n* ``readinto``\n* ``readline``\n* ``readlines``\n* ``seek``\n* ``seekable``\n* ``tell``\n* ``truncate``\n* ``writable``\n* ``write``\n* ``writelines``\n\nIn case of failure, one of the usual exceptions will be raised.\n\nThe ``aiofiles.os`` module contains executor-enabled coroutine versions of\nseveral useful ``os`` functions that deal with files:\n\n* ``stat``\n* ``sendfile``\n\nLimitations and Differences from the Builtin File API\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nWhen using Python 3.5 or greater, aiofiles file objects can be used as\nasynchronous context managers. Asynchronous iteration is also supported.\n\n.. code-block:: python\n\n async with aiofiles.open('filename') as f:\n async for line in f:\n ...\n\nWhen using Python 3.3 or 3.4, be aware that the closing of a file may block,\nand yielding from a coroutine while exiting from a context manager isn't\npossible, so aiofiles file objects can't be used as (ordinary, non-async)\ncontext managers. Use the ``try/finally`` construct from the introductory\nsection to ensure files are closed.\n\nWhen using Python 3.3 or 3.4, iteration is also unsupported. To iterate over a\nfile, call ``readline`` repeatedly until an empty result is returned. Keep in\nmind ``readline`` doesn't strip newline characters.\n\n.. code-block:: python\n\n f = yield from aiofiles.open('filename')\n try:\n while True:\n line = yield from f.readline()\n if not line:\n break\n line = line.strip()\n ...\n finally:\n yield from f.close()\n\nContributing\n~~~~~~~~~~~~\nContributions are very welcome. Tests can be run with ``tox``, please ensure\nthe coverage at least stays the same before you submit a pull request.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Tinche/aiofiles", "keywords": "", "license": "Apache 2.0", "maintainer": "", "maintainer_email": "", "name": "aiofiles-ext", "package_url": "https://pypi.org/project/aiofiles-ext/", "platform": "", "project_url": "https://pypi.org/project/aiofiles-ext/", "project_urls": { "Homepage": "https://github.com/Tinche/aiofiles" }, "release_url": "https://pypi.org/project/aiofiles-ext/0.4.0/", "requires_dist": null, "requires_python": "", "summary": "File support for asyncio.", "version": "0.4.0" }, "last_serial": 3021146, "releases": { "0.4.0": [ { "comment_text": "", "digests": { "md5": "1a7d5ad2a4fefe384005a1147449213d", "sha256": "a3075d91792153f5d60ec3b0ff892a6be7d6e350e5182397aad845728ea1cac3" }, "downloads": -1, "filename": "aiofiles-ext-0.4.0.tar.gz", "has_sig": false, "md5_digest": "1a7d5ad2a4fefe384005a1147449213d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5829, "upload_time": "2017-07-13T18:45:47", "url": "https://files.pythonhosted.org/packages/32/ec/f78e3e282facb113b1b192e092b06a217b545109f18941b6a35166bb3dd5/aiofiles-ext-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1a7d5ad2a4fefe384005a1147449213d", "sha256": "a3075d91792153f5d60ec3b0ff892a6be7d6e350e5182397aad845728ea1cac3" }, "downloads": -1, "filename": "aiofiles-ext-0.4.0.tar.gz", "has_sig": false, "md5_digest": "1a7d5ad2a4fefe384005a1147449213d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5829, "upload_time": "2017-07-13T18:45:47", "url": "https://files.pythonhosted.org/packages/32/ec/f78e3e282facb113b1b192e092b06a217b545109f18941b6a35166bb3dd5/aiofiles-ext-0.4.0.tar.gz" } ] }