Skip to content

Commit

Permalink
bump version to 1.0.0rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantintogoi committed Oct 13, 2024
1 parent ef3c21f commit d52e674
Show file tree
Hide file tree
Showing 35 changed files with 1,314 additions and 1,427 deletions.
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

18 changes: 18 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
httpx = "==0.24.1"

[dev-packages]
sphinx = "<6.0.0"
mkdocs = "<1.6.0"
mkdocs-material = "<9.3.0"
pytest = "<8.0.0"
pytest-asyncio = "<0.22.0"
pytest-localserver = "<1.0.0"

[requires]
python_version = "3.7"
812 changes: 812 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

64 changes: 14 additions & 50 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,50 +1,35 @@
.. image:: https://img.shields.io/badge/license-BSD-blue.svg
:target: https://github.com/KonstantinTogoi/aiovkcom/blob/master/LICENSE
:target: https://github.com/konstantintogoi/aiovkcom/blob/master/LICENSE

.. image:: https://img.shields.io/pypi/v/aiovkcom.svg
:target: https://pypi.python.org/pypi/aiovkcom

.. image:: https://img.shields.io/pypi/pyversions/aiovkcom.svg
:target: https://pypi.python.org/pypi/aiovkcom

.. image:: https://readthedocs.org/projects/aiovkcom/badge/?version=latest
:target: https://aiovkcom.readthedocs.io/en/latest/

.. image:: https://travis-ci.com/KonstantinTogoi/aiovkcom.svg
:target: https://travis-ci.com/KonstantinTogoi/aiovkcom

.. index-start-marker1
aiovkcom
========

aiovkcom is a python `vk.com API <https://vk.com/dev/api_requests>`_ wrapper.
The main features are:

* authorization (`Authorization Code <https://oauth.net/2/grant-types/authorization-code/>`_, `Implicit Flow <https://oauth.net/2/grant-types/implicit/>`_)
* `REST API <https://vk.com/dev/methods>`_ methods
async python `vk.com API <https://dev.vk.com/en/api/api-requests>`_ wrapper
for `REST API <https://dev.vk.com/en/method>`_ methods, see
`documentation <https://konstantintogoi.github.io/aiovkcom>`_.

Usage
-----
Example
-------

To use `vk.com API <https://vk.com/dev/api_requests>`_ you need
a registered app and `vk.com <https://vk.com>`_ account.
For more details, see
`aiovkcom Documentation <https://aiovkcom.readthedocs.io/>`_.
To use `vk.com API <https://dev.vk.com/en/api/api-requests>`_ you need
an :code:`access_token`.

.. code-block:: python
from aiovkcom import TokenSession, API
session = TokenSession(access_token, v='5.101')
api = API(session)
import aiovkcom
events = await api.wall.get()
friends = await api.friends.get()
Pass :code:`access_token` that was received after authorization.
For more details, see
`aiovkcom Documentation <https://aiovkcom.readthedocs.io/>`_.
async with aiovkcom.API(v='5.241', access_token='your access token') as vk:
contacts = await vk.account.getContactList()
friends = await vk.friends.get()
events = await vk.wall.get()
Installation
------------
Expand All @@ -53,34 +38,13 @@ Installation
$ pip install aiovkcom
or

.. code-block:: shell
$ python setup.py install
Supported Python Versions
-------------------------

Python 3.5, 3.6, 3.7 and 3.8 are supported.
Python 3.7, 3.8, 3.9 are supported.

.. index-end-marker1
Test
----

Run all tests.

.. code-block:: shell
$ python setup.py test
Run tests with PyTest.

.. code-block:: shell
$ python -m pytest [-k TEST_NAME]
License
-------

Expand Down
19 changes: 2 additions & 17 deletions aiovkcom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,2 @@
from . import api, exceptions, parsers, sessions
from .exceptions import (
Error,
OAuthError,
InvalidGrantError,
InvalidUserError,
APIError,
EmptyResponseError,
)
from .sessions import (
TokenSession,
CodeSession,
ImplicitSession,
)
from .api import API

__version__ = '0.1.0.post2'
"""aiovkcom."""
from .api import API # noqa: F401
73 changes: 63 additions & 10 deletions aiovkcom/api.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,87 @@
"""vk.com API."""
from typing import Any, Dict, Generator, Tuple

from .sessions import TokenSession
from .session import TokenSession


class API:
"""vk.com REST API."""
"""vk.com API.
Attributes:
session (TokenSession): session.
"""

__slots__ = ('session', )

def __init__(self, session: TokenSession):
self.session = session
def __init__(self, v: str, access_token: str) -> None:
"""Set session."""
self.session = TokenSession(v=v, access_token=access_token)

def __await__(self) -> Generator['API', None, None]:
"""Await self."""
yield self

async def __aenter__(self) -> 'API':
"""Enter."""
return self

def __getattr__(self, name):
async def __aexit__(self, *args: Tuple[Any, Any, Any]) -> None:
"""Exit."""
if self.session.client.is_closed is False:
await self.session.client.aclose()

def __getattr__(self, name) -> 'APIMethod':
"""Return an API method."""
return APIMethod(self, name)

async def __call__(self, name, **params):
async def __call__(self, name: str, **params: Dict[str, Any]) -> 'APIMethod': # noqa
"""Call an API method by its name.
Args:
name (str): full method's name
params (Dict[str, Any]): query parameters
Return:
APIMethod
"""
return await getattr(self, name)(**params)


class APIMethod:
"""vk.com REST API method."""
"""vk.com REST API method.
Attributes:
api (API): API instance
name (str): full method's name
"""

__slots__ = ('api', 'name')

def __init__(self, api: API, name: str):
def __init__(self, api: API, name: str) -> None:
"""Set method name."""
self.api = api
self.name = name

def __getattr__(self, name):
def __getattr__(self, name: str) -> 'APIMethod':
"""Chain methods.
Args:
name (str): method name
"""
return APIMethod(self.api, self.name + '.' + name)

async def __call__(self, **params):
async def __call__(self, **params: Dict[str, Any]) -> Dict[str, Any]:
"""Execute a request.
Args:
params (Dict[str, Any]): query parameters
Returns:
Dict[str, Any]
"""
return await self.api.session.request(self.name, params)
81 changes: 0 additions & 81 deletions aiovkcom/exceptions.py

This file was deleted.

35 changes: 0 additions & 35 deletions aiovkcom/parsers.py

This file was deleted.

Loading

0 comments on commit d52e674

Please sign in to comment.