Convert trollius code to asyncio
A tool based on lib2to3 for converting code using trollius to use asyncio. After installation, run trollius2asyncio. It works in the same way as 2to3.
For example, it will transform this:
import trollius from trollius import From, Return @trollius.coroutine def double_future(future): value = yield From(future) raise Return(2 * value)
import asyncio async def double_future(future): value = await future return 2 * value
After installation, run
trollius2asyncio as you would
2to3. It takes the
same command-line arguments, including
-h for help.
taking the imports into consideration. Thus, importing trollius as a different
name will confuse it, and
from tornado.gen import Return will cause the
returns from Tornado to also be rewritten (which should still be a legal
@trollius.coroutine, again without taking imports into
consideration. If the decorator is omitted, it won't turn the function into a
coroutine, which will lead to syntax errors if it ends up containing
statements. It also won't apply the transformation if there are additional
decorators inside (i.e., between
@trollius.coroutine and the definition)
since that would alter the semantics.
The resulting code is not necessarily well-styled e.g., the extra blank line in the example above. These are limitations of lib2to3 and won't be easy to fix without risking breaking code in corner cases.
- Drop Python 3.4 support (output code uses async and await).
- Add licence.
- Initial release.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size trollius_fixers-0.2-py2.py3-none-any.whl (10.1 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size trollius-fixers-0.2.tar.gz (4.6 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for trollius_fixers-0.2-py2.py3-none-any.whl