Skip to content

Commit 27a799b

Browse files
committed
start refactore
1 parent cb8a1d6 commit 27a799b

16 files changed

Lines changed: 413 additions & 600 deletions

.gitattributes

Lines changed: 0 additions & 4 deletions
This file was deleted.

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.PHONY: help install install-dev test test-quick lint format type-check clean build docs example-docs build-all-docs serve-docs serve-examples ci-test prepare-release generate-badges
2+
3+
install:
4+
pip install .
5+
6+
install-dev:
7+
pip install -e .[dev]
8+
9+
test:
10+
pytest --cov=chizhik_api --cov-report=xml --cov-report=html --cov-report=term-missing
11+
12+
test-quick:
13+
pytest --tb=short
14+
15+
format:
16+
black chizhik_api/ tests/
17+
isort chizhik_api/ tests/
18+
19+
clean:
20+
rm -rf build/ dist/ *.egg-info/
21+
rm -rf docs/_build/ examples/docs/_build/
22+
rm -rf htmlcov/ .coverage coverage.xml coverage.svg
23+
rm -rf .pytest_cache/
24+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
25+
find . -type f -name "*.pyc" -delete
26+
27+
build: clean
28+
python -m build
29+
30+
build-install:
31+
$(MAKE) build
32+
$(MAKE) install
33+
34+
docs:
35+
cd docs && sphinx-build -b html source _build/html
36+
37+
serve-docs:
38+
cd docs/_build/html && python -m http.server 8000

create_index_schema.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

json_schema_for_humans_config.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pyaterochka_api import PyaterochkaAPI
2+
3+
async def main():
4+
# RUS: Использование проксирования опционально. Вы можете создать несколько агентов с разными прокси для ускорения парса.
5+
# ENG: Proxy usage is optional. You can create multiple agents with different proxies for faster parsing.
6+
async with PyaterochkaAPI(headless=False) as API:
7+
# RUS: Выводит активные предложения магазина
8+
# ENG: Outputs active offers of the store
9+
print(f"Active offers output: {(await API.Advertising.active_inout()).json()!s:.100s}...\n")
10+
11+
import asyncio
12+
asyncio.run(main())

pyaterochka_api/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from .manager import Pyaterochka
1+
from .manager import PyaterochkaAPI
22
from .enums import PurchaseMode
33

44
__version__ = "0.2.0.1"
5-
__all__ = ['Pyaterochka', 'PurchaseMode']
5+
__all__ = ['PyaterochkaAPI', 'PurchaseMode']

pyaterochka_api/api.py

Lines changed: 0 additions & 168 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Реклама"""
2+
3+
from typing import TYPE_CHECKING
4+
5+
from human_requests.abstraction import FetchResponse, HttpMethod
6+
7+
if TYPE_CHECKING:
8+
from ..old import ChizhikAPI
9+
10+
11+
class ClassAdvertising:
12+
"""Методы для работы с рекламными материалами Перекрёстка.
13+
14+
Включает получение баннеров, слайдеров, буклетов и другого рекламного контента.
15+
"""
16+
17+
def __init__(self, parent: "ChizhikAPI", CATALOG_URL: str):
18+
self._parent: "ChizhikAPI" = parent
19+
self.CATALOG_URL: str = CATALOG_URL
20+
21+
async def get_news(self, limit: int | None = None) -> FetchResponse:
22+
"""
23+
Asynchronously retrieves news from the Pyaterochka API.
24+
25+
Args:
26+
limit (int, optional): The maximum number of news items to retrieve. Defaults to None.
27+
28+
Returns:
29+
dict: A dictionary representing the news if the request is successful, error otherwise.
30+
"""
31+
url = f"{self.BASE_URL}/api/public/v1/news/"
32+
if limit and limit > 0:
33+
url += f"?limit={limit}"
34+
35+
_is_success, response, _response_type = await self.api.fetch(url=url)
36+
37+
return response

0 commit comments

Comments
 (0)