Skip to content

Commit

Permalink
upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantintogoi committed Aug 4, 2024
1 parent f737433 commit 50a3f8f
Show file tree
Hide file tree
Showing 37 changed files with 2,156 additions and 2,877 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"
sphinx = "==5.1.1"
mkdocs = "==1.3.1"
mkdocs-material = "==8.4.0"

[dev-packages]
pytest-dotenv = "==0.5.2"
pytest-asyncio = "==0.21.0"
pytest-localserver = "==0.7.1"

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

Large diffs are not rendered by default.

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

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

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

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

.. image:: https://travis-ci.org/KonstantinTogoi/aiomailru.svg
:target: https://travis-ci.org/KonstantinTogoi/aiomailru

.. index-start-marker1
aiomailru
Expand All @@ -31,7 +25,7 @@ Usage
To use `Mail.Ru API <https://api.mail.ru/>`_ you need a registered app and
`Mail.Ru <https://mail.ru>`_ account.
For more details, see
`aiomailru Documentation <https://aiomailru.readthedocs.io/>`_.
`aiomailru Documentation <https://konstantintogoi.github.io/aiomailru>`_.

Client application
~~~~~~~~~~~~~~~~~~
Expand All @@ -55,7 +49,7 @@ i.e. when you embed your app's info (private key) in publicly available code.
Use :code:`access_token` and :code:`uid`
that were received after authorization. For more details, see
`authorization instruction <https://aiomailru.readthedocs.io/en/latest/authorization.html>`_.
`authorization instruction <https://konstantintogoi.github.io/aiomailru/authorization>`_.

Server application
~~~~~~~~~~~~~~~~~~
Expand All @@ -77,7 +71,7 @@ Use :code:`ServerSession` when REST API is needed in:
Use :code:`access_token` that was received after authorization.
For more details, see
`authorization instruction <https://aiomailru.readthedocs.io/en/latest/authorization.html>`_.
`authorization instruction <https://konstantintogoi.github.io/aiomailru/authorization>`_.

Installation
------------
Expand Down
33 changes: 2 additions & 31 deletions aiomailru/__init__.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,4 @@
from . import api, exceptions, objects, parsers, sessions, utils
from .utils import parseaddr
from .exceptions import (
Error,
OAuthError,
InvalidGrantError,
InvalidClientError,
APIError,
APIScrapperError,
CookieError,
)
from .sessions import (
PublicSession,
TokenSession,
ClientSession,
ServerSession,
CodeSession,
CodeClientSession,
CodeServerSession,
ImplicitSession,
ImplicitClientSession,
ImplicitServerSession,
PasswordSession,
PasswordClientSession,
PasswordServerSession,
RefreshSession,
RefreshClientSession,
RefreshServerSession,
)
from .api import API

"""aiomailru."""
from . import api, sessions # noqa: F401

__version__ = '0.1.1.post1'
53 changes: 44 additions & 9 deletions aiomailru/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""My.Mail.Ru API."""
from typing import Any, Dict

from .sessions import TokenSession

Expand All @@ -8,28 +9,62 @@ class API:

__slots__ = ('session', )

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

def __getattr__(self, name):
def __getattr__(self, name: str) -> '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
Returns:
APIMethod
"""
return await getattr(self, name)(**params)


class APIMethod:
"""Platform@Mail.Ru REST API method."""
"""Platform@Mail.Ru 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):
return APIMethod(self.api, self.name + '.' + name)
def __getattr__(self, name: str) -> 'APIMethod':
"""Chain methods.
Args:
name (str): method name
"""
return APIMethod(self.api, f'{self.name}.{name}')

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]
async def __call__(self, **params):
"""
params['method'] = self.name
return await self.api.session.request(params=params)
return await self.api.session.request('', params=params)
91 changes: 0 additions & 91 deletions aiomailru/browser.py

This file was deleted.

Loading

0 comments on commit 50a3f8f

Please sign in to comment.