Only the standard library... but asynchronous!
Project description
aiostdlib
[!WARNING] The library is in the pre-alpha stage.
Key Features
- Provides asynchronous version of the standard library;
- The same API as the Python's standard, blocking API;
- Blocking IO is performed in a separate thread.
Getting Started
Installation
The library is available as aiostdlib on PyPI:
pip install aiostdlib
Usage
The aiostdlib API is the same as the standard library (v3.13), except that it is asynchronous.
[SOON] builtins
For more, see the documentation.
import asyncio
from aiostdlib import builtins
async def main() -> None:
async with builtins.open("./aiostdlib.txt", mode="w") as file:
await file.write("aiostdlib")
if __name__ == "__main__":
asyncio.run(main())
[SOON] io
For more, see the documentation.
import asyncio
from aiostdlib import io
async def main() -> None:
async with io.open_code("aiostdlib.py") as file:
data = await file.read()
if __name__ == "__main__":
asyncio.run(main())
json
For more, see the documentation.
import asyncio
from aiostdlib import builtins, json
async def main() -> None:
async with builtins.open("./aiostdlib.json", mode="w") as file:
await json.dump(["aiostdlib"], file)
if __name__ == "__main__":
asyncio.run(main())
[SOON] pathlib
For more, see the documentation.
import asyncio
from aiostdlib import pathlib
async def main() -> None:
path = pathlib.Path("./aiostdlib.txt")
if not await path.exists():
await path.write_text("aiostdlib")
if __name__ == "__main__":
asyncio.run(main())
[SOON] shutil
For more, see the documentation.
import asyncio
from aiostdlib import shutil
async def main() -> None:
await shutil.rmtree("/tmp/aiostdlib/")
if __name__ == "__main__":
asyncio.run(main())
[SOON] tarfile
For more, see the documentation.
import asyncio
from aiostdlib import tarfile
async def main() -> None:
if not await tarfile.is_tarfile("./aiostdlib.tar.gz"):
detail = "The file is not a `tar` archive"
raise RuntimeError(detail)
if __name__ == "__main__":
asyncio.run(main())
[SOON] tempfile
For more, see the documentation.
import asyncio
from aiostdlib import tempfile
async def main() -> None:
tempdir, path = await asyncio.gather(
tempfile.gettempdir(),
tempfile.mkdtemp(),
)
if not path.startswith(tempdir):
detail = "This is strange..."
raise RuntimeError(detail)
if __name__ == "__main__":
asyncio.run(main())
tomllib
For more, see the documentation.
import asyncio
from aiostdlib import builtins, tomllib
async def main() -> None:
async with builtins.open("./aiostdlib.toml", mode="rb") as file:
data = await tomllib.load(file)
if "aiostdlib" not in data:
detail = "Where is 'aiostdlib'?"
raise RuntimeError(detail)
if __name__ == "__main__":
asyncio.run(main())
[SOON] zipfile
For more, see the documentation.
import asyncio
from aiostdlib import zipfile
async def main() -> None:
if not await zipfile.is_zipfile("./aiostdlib.zip"):
detail = "The file is not a `zip` archive"
raise RuntimeError(detail)
if __name__ == "__main__":
asyncio.run(main())
License
MIT License, Copyright (c) 2024 Sergei Bogdanov. See LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiostdlib-0.1.0.tar.gz.
File metadata
- Download URL: aiostdlib-0.1.0.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63989ef2daed8a2fe778e83d4c6ccc977533d1d7ed200109a913031bfed3c31c
|
|
| MD5 |
4eda4206fc52c6f89960977165d6cac2
|
|
| BLAKE2b-256 |
e9f87cf6aedf78a5409b407b6a612d11622d4e88ec14061edaa814a4fce699f2
|
File details
Details for the file aiostdlib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aiostdlib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de0f808f4c100c4221ce54431a4aac72278e390c415773c2c5a084a88e16df44
|
|
| MD5 |
c0c8c29a3b92b27737a60c461d09aa66
|
|
| BLAKE2b-256 |
0dfa8be29018bf5e8a1e9ac66d53d33f2a2a4f931b8bacc0d6e615baa7291d9a
|