Open graingert opened 5 years ago
Hi @graingert, I released aiopath
, an async implementation of pathlib
, that does just this. It uses some features from aiofiles
, as well.
To illustrate using your example with aiopath
:
import asyncio
from aiostream import stream
from aiopath import AsyncPath as Path
async def export_as_js(p: Path) -> None:
t = await p.read_text()
await asyncio.gather(
p.with_suffix('.js').write_text(f'export default `{t}`;'),
p.unlink(),
)
async def amain():
await stream.map(Path('.').glob('**/*.html'), export_as_js)
def main():
asyncio.run(amain())
main()
Check out the README for more examples.
aiopath
is licensed under the LGPLv3, and it's available on PyPI. You can install it like so: python3 -m pip install aiopath
.
so we can do things like: