Skip to content

Commit d836f60

Browse files
committed
complete Product.info, new version 0.2.3
1 parent ca16cde commit d836f60

13 files changed

Lines changed: 11137 additions & 9913 deletions

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ install-dev:
77
pip install -e .[dev]
88

99
test:
10-
pytest --cov=chizhik_api --cov-report=xml --cov-report=html --cov-report=term-missing
10+
pytest --cov=fixprice_api --cov-report=xml --cov-report=html --cov-report=term-missing
1111

1212
test-quick:
1313
pytest --tb=short
@@ -19,8 +19,8 @@ type-check:
1919
python -m mypy fixprice_api
2020

2121
format:
22-
black chizhik_api/ tests/
23-
isort chizhik_api/ tests/
22+
black fixprice_api/ tests/
23+
isort fixprice_api/ tests/
2424

2525
clean:
2626
rm -rf build/ dist/ *.egg-info/

fixprice_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .abstraction import CatalogSort
33

44
__all__ = ["FixPriceAPI", "CatalogSort"]
5-
__version__ = "0.2.2"
5+
__version__ = "0.2.3"

fixprice_api/abstraction.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
class CatalogSort:
32
POPULARITY = "sold"
43
"""Сначало самые популярные"""

fixprice_api/endpoints/catalog.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def balance(
106106
url += "&inStock=true"
107107

108108
return await self._parent._request(HttpMethod.GET, url)
109-
109+
110110
@overload
111111
async def info(self, *, url: str): ...
112112

@@ -135,7 +135,9 @@ async def info(
135135
real_url = "https://fix-price.com/catalog/"
136136
if url is None:
137137
if category is None or product_id is None or slug is None:
138-
raise TypeError("Either url or (category, product_id, slug) must be provided")
138+
raise TypeError(
139+
"Either url or (category, product_id, slug) must be provided"
140+
)
139141

140142
real_url += f"{category}/p-{product_id}-{slug}"
141143
else:
@@ -171,7 +173,11 @@ async def info(
171173
}
172174
""")
173175

174-
nuxt_data = json.loads(raw_json)["data"][0]["categoryData"]["product"] if raw_json else None
176+
nuxt_data = (
177+
json.loads(raw_json)["data"][0]["categoryData"]["product"]
178+
if raw_json
179+
else None
180+
)
175181

176182
def _json(self):
177183
return AwaitableDict(nuxt_data)

fixprice_api/endpoints/general.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ async def download_image(
2626
attempts=retry_attempts, start_timeout=3.0, max_timeout=timeout
2727
)
2828

29-
px = self._parent.proxy if isinstance(self._parent.proxy, Proxy) else Proxy(self._parent.proxy)
29+
px = (
30+
self._parent.proxy
31+
if isinstance(self._parent.proxy, Proxy)
32+
else Proxy(self._parent.proxy)
33+
)
3034
async with RetryClient(retry_options=retry_options) as retry_client:
3135
async with retry_client.get(
3236
url, raise_for_status=True, proxy=px.as_str()

fixprice_api/tools.py

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
21
class AwaitableDict(dict):
3-
def __init__(self, data: dict | None):
4-
self._data = data
5-
6-
def __getitem__(self, key):
7-
return self._data[key]
8-
9-
def __iter__(self):
10-
return iter(self._data)
11-
12-
def __len__(self):
13-
return len(self._data)
14-
15-
def __repr__(self):
16-
return repr(self._data)
17-
18-
def get(self, key, default=None):
19-
return self._data.get(key, default)
20-
212
def __await__(self):
223
async def _wrap():
23-
return self._data
4+
return dict(self)
5+
246
return _wrap().__await__()

requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ aiohttp-retry
66
pytest
77
pytest-anyio
88
pytest-jsonschema-snapshot
9-
pillow
9+
pillow
10+
11+
black
12+
flake8
13+
mypy
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
{
2+
"id": 1912108,
3+
"title": "Воздушное суфле \"Весенняя серия\", Пухлый Кролик, 150 г",
4+
"sku": "1912108",
5+
"category": 2004,
6+
"isFresh": false,
7+
"isNew": false,
8+
"isPromo": false,
9+
"isSeason": false,
10+
"isHit": false,
11+
"isFavorite": false,
12+
"isCart": false,
13+
"isQRMark": false,
14+
"image": 2423776,
15+
"adult": false,
16+
"description": "Воздушное суфле \"Весенняя серия\", Пухлый Кролик, со вкусом пломбира имеет нежную текстуру. Разноцветное, фигурное. Масса нетто: 150 г.",
17+
"video": null,
18+
"videoLink": null,
19+
"forbidden": false,
20+
"active": true,
21+
"unitType": null,
22+
"specialPrice": null,
23+
"images": [
24+
{
25+
"id": 2423776,
26+
"title": null,
27+
"src": "https://img.fix-price.com/insecure/rs:fit:800:800/plain/pim/images/_default_upload_bucket/1912108_1.jpg"
28+
},
29+
{
30+
"id": 2423777,
31+
"title": null,
32+
"src": "https://img.fix-price.com/insecure/rs:fit:800:800/plain/pim/images/_default_upload_bucket/1912108.jpg"
33+
}
34+
],
35+
"properties": [
36+
{
37+
"id": 12,
38+
"alias": "prodCountry",
39+
"value": "Россия",
40+
"title": "Страна производства"
41+
},
42+
{
43+
"id": 13,
44+
"alias": "manufacturer",
45+
"value": "ООО \"ТД \"Алтей\"",
46+
"title": "Производитель"
47+
}
48+
],
49+
"extraDescriptions": [
50+
{
51+
"id": 0,
52+
"alias": "nutritionalValue",
53+
"value": "Пищевая ценность на 100г. Продукта: белки 0г.; жиры 0г.; углеводы 0г. Энергетическая ценность: 0 ккал.",
54+
"title": "Пищевая ценность"
55+
},
56+
{
57+
"id": 1,
58+
"alias": "composition",
59+
"value": "Сахар, патока крахмальная,желатин пищевой,крахмал кукурузный,ароматизатор пломбир, красители синий блестящий, желтый хинолиновый, понсо 4R.",
60+
"title": "Состав"
61+
},
62+
{
63+
"id": 2,
64+
"alias": "manufacturerAddress",
65+
"value": "623733, Свердловская область, Режевской район, село Останино, ул. Центральная, д.10",
66+
"title": "Адрес производителя"
67+
},
68+
{
69+
"id": 3,
70+
"alias": "nutritionalValueSeparated",
71+
"value": {
72+
"description": "Пищевая ценность на 100г",
73+
"energyValue": "",
74+
"protein": "",
75+
"fats": "",
76+
"carbohydrates": ""
77+
},
78+
"title": "Пищевая ценность с разбивкой по элементам"
79+
}
80+
],
81+
"variants": [
82+
{
83+
"id": 65185,
84+
"image": null,
85+
"title": "",
86+
"width": 60,
87+
"height": 140,
88+
"length": 270,
89+
"weight": 152,
90+
"barcode": "1912108",
91+
"properties": [
92+
{
93+
"id": 100,
94+
"alias": "fake",
95+
"value": "Ассортимент",
96+
"title": "Вариант"
97+
}
98+
],
99+
"count": 10,
100+
"price": "59.00",
101+
"dimensions": {
102+
"width": 60,
103+
"height": 140,
104+
"weight": 152,
105+
"length": 270,
106+
"isPackage": true
107+
},
108+
"fixPrice": "59.00",
109+
"unitPrice": ""
110+
},
111+
{
112+
"id": 65184,
113+
"image": 1688072,
114+
"title": "",
115+
"width": 60,
116+
"height": 140,
117+
"images": [
118+
{
119+
"id": 1688072,
120+
"src": "https://img.fix-price.com/insecure/rs:fit:800:800/plain/pim/images/_default_upload_bucket/25b9c9d882e1461afeaafafc89eab494_1.jpg",
121+
"title": null
122+
}
123+
],
124+
"length": 270,
125+
"weight": 152,
126+
"barcode": "4650139150280",
127+
"properties": [
128+
{
129+
"id": 9,
130+
"alias": "variant",
131+
"value": "Пломбир",
132+
"title": "Вариант"
133+
}
134+
],
135+
"count": 6,
136+
"price": "59.00",
137+
"dimensions": {
138+
"width": 60,
139+
"height": 140,
140+
"weight": 152,
141+
"length": 270,
142+
"isPackage": true
143+
},
144+
"fixPrice": "59.00",
145+
"unitPrice": ""
146+
}
147+
],
148+
"unitPrice": "",
149+
"url": "produkty-i-napitki/p-1912108-vozdushnoe-sufle-vesennyaya-seriya-puhlyy-krolik-150-g",
150+
"brand": {
151+
"id": 373,
152+
"src": "",
153+
"url": null,
154+
"alias": "",
155+
"login": null,
156+
"title": "Пухлый Кролик",
157+
"updated_at": null,
158+
"isSTM": false,
159+
"isFavorite": false
160+
},
161+
"informers": [
162+
{
163+
"alias": "loyaltyProgram"
164+
}
165+
],
166+
"bonusCommunicationEnable": false,
167+
"_headers": {
168+
"x-language": "ru",
169+
"x-city": "3",
170+
"is-logged": "",
171+
"x-logged": "",
172+
"vary": "X-City, X-Language, X-Pfm, X-Delivery-Type, X-Logged",
173+
"cache-control": "public, max-age=3600",
174+
"content-type": "application/json; charset=UTF-8",
175+
"access-control-allow-origin": "*",
176+
"access-control-allow-methods": "GET, POST, PUT, DELETE, HEAD, OPTIONS",
177+
"access-control-allow-headers": "X-Client-Route, X-Access-Token, Content-Type, X-Key, X-Count, Is-Logged, X-Language, X-City, X-Region, X-Country, X-Pfm, X-Mark, X-Delivery-Type, X-Web-Application-Type, X-Open-Id, Cache-Control, Vary, X-Logged",
178+
"access-control-expose-headers": "X-Key, X-Count, Is-Logged, X-Language, X-City, X-Region, X-Country, X-Pfm, X-Mark, X-Web-Application-Type, X-Open-Id, X-Child, Cache-Control, Vary, X-Logged",
179+
"access-control-allow-credentials": "true",
180+
"access-control-max-age": "3600",
181+
"server": "Unit/1.34.2",
182+
"date": "Sat, 14 Mar 2026 20:56:16 GMT",
183+
"transfer-encoding": "chunked"
184+
}
185+
}

0 commit comments

Comments
 (0)