add PYTHONPATH environment variable to Dockerfile

This commit is contained in:
2025-10-19 22:48:19 +03:00
parent 9d8d5d1ccf
commit 50c523220b
8 changed files with 80 additions and 2 deletions

4
.gitignore vendored
View File

@ -14,8 +14,8 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
#lib/
#lib64/
parts/
sdist/
var/

1
src/app/lib/__init__.py Normal file
View File

@ -0,0 +1 @@
from .tbank_client import TBankClient

View File

@ -0,0 +1,3 @@
from .client import BaseClient
from .httpx_client import HTTPXClient
from .niquests_client import NiquestsClient

View File

@ -0,0 +1,18 @@
from abc import ABC, abstractmethod
from typing import Optional
class BaseClient(ABC):
@abstractmethod
async def _method(self, method: str, path: str, data: Optional[dict] = None, params: Optional[dict] = None) -> dict:
raise NotImplementedError("_method must be implemented by subclasses")
@property
@abstractmethod
def base_url(self) -> str:
raise NotImplementedError("Subclasses must implement base_url property")
@property
@abstractmethod
def headers(self) -> dict:
raise NotImplementedError("Subclasses must implement headers property")

View File

@ -0,0 +1,22 @@
from abc import ABC
from typing import Optional
import httpx
from .client import BaseClient
class HTTPXClient(BaseClient, ABC):
async def _method(self, method: str, path: str, data: Optional[dict] = None, params: Optional[dict] = None) -> dict:
async with httpx.AsyncClient() as client:
url = self.base_url + path
headers = self.headers
request = client.build_request(
method,
url,
json=data,
params=params,
headers=headers
)
response = await client.send(request)
return response.json()

View File

@ -0,0 +1,14 @@
from abc import ABC
from typing import Optional
import niquests.async_api
from .client import BaseClient
class NiquestsClient(BaseClient, ABC):
async def _method(self, method: str, path: str, data: Optional[dict] = None, params: Optional[dict] = None) -> dict:
url = self.base_url + path
headers = self.headers
response = await niquests.async_api.request(method, url, params=params, json=data, headers=headers)
return response.json()

View File

@ -0,0 +1 @@
from .client import TBankClient

View File

@ -0,0 +1,19 @@
from typing import Any, Coroutine
from ..base_client import BaseClient, NiquestsClient
class TBankClient(NiquestsClient):
@property
def headers(self) -> dict:
return {'Authorization': 'Bearer ' + self.api_key}
@property
def base_url(self) -> str:
return "https://business.tbank.ru/openapi/api"
def __init__(self, api_key: str):
self.api_key = api_key
async def get_counterparty_excerpt_by_inn(self, inn: str) -> dict:
return await self._method('GET', '/v1/counterparty/excerpt/by-inn', params={'inn': inn})