Skip to main content

Only the standard library... but asynchronous!

Project description

aiostdlib

PyPI Version PyPI Downloads License Python Version

[!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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiostdlib-0.1.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiostdlib-0.1.0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

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

Hashes for aiostdlib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 63989ef2daed8a2fe778e83d4c6ccc977533d1d7ed200109a913031bfed3c31c
MD5 4eda4206fc52c6f89960977165d6cac2
BLAKE2b-256 e9f87cf6aedf78a5409b407b6a612d11622d4e88ec14061edaa814a4fce699f2

See more details on using hashes here.

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

Hashes for aiostdlib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de0f808f4c100c4221ce54431a4aac72278e390c415773c2c5a084a88e16df44
MD5 c0c8c29a3b92b27737a60c461d09aa66
BLAKE2b-256 0dfa8be29018bf5e8a1e9ac66d53d33f2a2a4f931b8bacc0d6e615baa7291d9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page