From ce2460c5e3738c24b25ab38b123955dfb2f99675 Mon Sep 17 00:00:00 2001 From: Ryan Northey Date: Mon, 4 Sep 2023 22:14:07 +0100 Subject: [PATCH] `aio.web`: Add app Signed-off-by: Ryan Northey --- README.md | 15 +++++++ aio.web/BUILD | 2 + aio.web/README.rst | 5 +++ aio.web/VERSION | 1 + aio.web/aio/web/BUILD | 17 ++++++++ aio.web/aio/web/__init__.py | 14 +++++++ aio.web/aio/web/abstract/__init__.py | 7 ++++ aio.web/aio/web/abstract/downloader.py | 14 +++++++ aio.web/aio/web/downloader.py | 16 ++++++++ aio.web/aio/web/exceptions.py | 7 ++++ aio.web/aio/web/interface.py | 18 +++++++++ aio.web/aio/web/py.typed | 0 aio.web/aio/web/typing.py | 0 aio.web/setup.cfg | 55 ++++++++++++++++++++++++++ aio.web/setup.py | 5 +++ 15 files changed, 176 insertions(+) create mode 100644 aio.web/BUILD create mode 100644 aio.web/README.rst create mode 100644 aio.web/VERSION create mode 100644 aio.web/aio/web/BUILD create mode 100644 aio.web/aio/web/__init__.py create mode 100644 aio.web/aio/web/abstract/__init__.py create mode 100644 aio.web/aio/web/abstract/downloader.py create mode 100644 aio.web/aio/web/downloader.py create mode 100644 aio.web/aio/web/exceptions.py create mode 100644 aio.web/aio/web/interface.py create mode 100644 aio.web/aio/web/py.typed create mode 100644 aio.web/aio/web/typing.py create mode 100644 aio.web/setup.cfg create mode 100644 aio.web/setup.py diff --git a/README.md b/README.md index 496b5bf82..192371a1c 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,21 @@ pypi: https://pypi.org/project/aio.run.runner --- +#### [aio.web](aio.web) + +version: 0.1.0.dev0 + +pypi: https://pypi.org/project/aio.web + +##### requirements: + +- [abstracts](https://pypi.org/project/abstracts) >=0.0.12 +- [aiohttp](https://pypi.org/project/aiohttp) +- [pyyaml](https://pypi.org/project/pyyaml) + +--- + + #### [dependatool](dependatool) version: 0.2.3.dev0 diff --git a/aio.web/BUILD b/aio.web/BUILD new file mode 100644 index 000000000..b42c30a6c --- /dev/null +++ b/aio.web/BUILD @@ -0,0 +1,2 @@ + +toolshed_package("aio.web") diff --git a/aio.web/README.rst b/aio.web/README.rst new file mode 100644 index 000000000..3e6f2e53f --- /dev/null +++ b/aio.web/README.rst @@ -0,0 +1,5 @@ + +aio.web +======= + +Web utils for asyncio. diff --git a/aio.web/VERSION b/aio.web/VERSION new file mode 100644 index 000000000..0d4d12494 --- /dev/null +++ b/aio.web/VERSION @@ -0,0 +1 @@ +0.1.0-dev diff --git a/aio.web/aio/web/BUILD b/aio.web/aio/web/BUILD new file mode 100644 index 000000000..3e5e8890e --- /dev/null +++ b/aio.web/aio/web/BUILD @@ -0,0 +1,17 @@ + +toolshed_library( + "aio.web", + dependencies=[ + "//deps:reqs#abstracts", + "//deps:reqs#aiohttp", + "//deps:reqs#pyyaml", + ], + sources=[ + "abstract/__init__.py", + "abstract/downloader.py", + "__init__.py", + "exceptions.py", + "interface.py", + "typing.py", + ], +) diff --git a/aio.web/aio/web/__init__.py b/aio.web/aio/web/__init__.py new file mode 100644 index 000000000..e74b3e282 --- /dev/null +++ b/aio.web/aio/web/__init__.py @@ -0,0 +1,14 @@ + +from .abstract import ( + ADownloader, + AChecksumDownloader) +from .interface import ( + IDownloader, + IChecksumDownloader) + + +__all__ = ( + "ADownloader", + "AChecksumDownloader", + "IDownloader", + "IChecksumDownloader") diff --git a/aio.web/aio/web/abstract/__init__.py b/aio.web/aio/web/abstract/__init__.py new file mode 100644 index 000000000..190a733ba --- /dev/null +++ b/aio.web/aio/web/abstract/__init__.py @@ -0,0 +1,7 @@ +from .downloader import ADownloader, AChecksumDownloader + + +__all__ = ( + "ADownloader", + "AChecksumDownloader", +) diff --git a/aio.web/aio/web/abstract/downloader.py b/aio.web/aio/web/abstract/downloader.py new file mode 100644 index 000000000..e57694428 --- /dev/null +++ b/aio.web/aio/web/abstract/downloader.py @@ -0,0 +1,14 @@ + +import abstracts + +from aio.web import interface + + +@abstracts.implementer(interface.IDownloader) +class ADownloader(metaclass=abstracts.Abstraction): + pass + + +@abstracts.implementer(interface.IChecksumDownloader) +class AChecksumDownloader(ADownloader, metaclass=abstracts.Abstraction): + pass diff --git a/aio.web/aio/web/downloader.py b/aio.web/aio/web/downloader.py new file mode 100644 index 000000000..7361dd628 --- /dev/null +++ b/aio.web/aio/web/downloader.py @@ -0,0 +1,16 @@ + +from typing import Type + +import abstracts + +from aio.web import abstract + + +@abstracts.implementer(abstract.ADownloader) +class Downloader: + pass + + +@abstracts.implementer(abstract.AChecksumDownloader) +class ChecksumDownloader: + pass diff --git a/aio.web/aio/web/exceptions.py b/aio.web/aio/web/exceptions.py new file mode 100644 index 000000000..527b5fa70 --- /dev/null +++ b/aio.web/aio/web/exceptions.py @@ -0,0 +1,7 @@ + +class ChecksumError(Exception): + pass + + +class DownloadError(Exception): + pass diff --git a/aio.web/aio/web/interface.py b/aio.web/aio/web/interface.py new file mode 100644 index 000000000..4e449227d --- /dev/null +++ b/aio.web/aio/web/interface.py @@ -0,0 +1,18 @@ + +import abstracts + + +class IDownloader(metaclass=abstracts.Interface): + + @abstracts.interfacemethod + async def download(self) -> int: + """Download content from the interwebs.""" + raise NotImplementedError + + +class IChecksumDownloader(IDownloader, metaclass=abstracts.Interface): + + @abstracts.interfacemethod + async def checksum(self, content) -> int: + """Checksum some content.""" + raise NotImplementedError diff --git a/aio.web/aio/web/py.typed b/aio.web/aio/web/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/aio.web/aio/web/typing.py b/aio.web/aio/web/typing.py new file mode 100644 index 000000000..e69de29bb diff --git a/aio.web/setup.cfg b/aio.web/setup.cfg new file mode 100644 index 000000000..f12a65423 --- /dev/null +++ b/aio.web/setup.cfg @@ -0,0 +1,55 @@ +[metadata] +name = aio.web +version = file: VERSION +author = Ryan Northey +author_email = ryan@synca.io +maintainer = Ryan Northey +maintainer_email = ryan@synca.io +license = Apache Software License 2.0 +url = https://github.com/envoyproxy/toolshed/tree/main/aio.web +description = A collection of functional utils for asyncio +long_description = file: README.rst +classifiers = + Development Status :: 4 - Beta + Framework :: Pytest + Intended Audience :: Developers + Topic :: Software Development :: Testing + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: Implementation :: CPython + Operating System :: OS Independent + License :: OSI Approved :: Apache Software License + +[options] +python_requires = >=3.8 +py_modules = aio.web +packages = find_namespace: +install_requires = + abstracts>=0.0.12 + aiohttp + pyyaml + +[options.extras_require] +test = + pytest + pytest-asyncio + pytest-coverage + pytest-iters + pytest-patches +lint = flake8 +types = + mypy +publish = wheel + +[options.package_data] +* = py.typed + +[options.packages.find] +include = aio.* +exclude = + build.* + tests.* + dist.* diff --git a/aio.web/setup.py b/aio.web/setup.py new file mode 100644 index 000000000..1f6a64b9c --- /dev/null +++ b/aio.web/setup.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python + +from setuptools import setup # type:ignore + +setup()