Skip to content

Commit 9bc9d66

Browse files
committed
Merge branch 'main' into release/1.4
2 parents 37ff968 + 127fccd commit 9bc9d66

15 files changed

Lines changed: 5009 additions & 2200 deletions

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ ci:
55
autoupdate_schedule: quarterly
66
repos:
77
- repo: https://github.com/keewis/blackdoc
8-
rev: v0.4.5
8+
rev: v0.4.6
99
hooks:
1010
- id: blackdoc
1111
files: \.py$
1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.14.3
13+
rev: v0.14.10
1414
hooks:
1515
- id: ruff-check
1616
args: [--fix, --exit-non-zero-on-fix]
@@ -28,7 +28,7 @@ repos:
2828
additional_dependencies: [toml]
2929
exclude: tests/
3030
- repo: https://github.com/asottile/pyupgrade
31-
rev: v3.21.0
31+
rev: v3.21.2
3232
hooks:
3333
- id: pyupgrade
3434
args: [--py39-plus, --keep-runtime-typing]

src/keepa/__init__.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,20 @@
88
except PackageNotFoundError:
99
__version__ = "unknown"
1010

11-
from keepa.data_models import ProductParams
12-
from keepa.interface import (
13-
DCODES,
14-
KEEPA_ST_ORDINAL,
15-
SCODES,
16-
AsyncKeepa,
17-
Domain,
18-
Keepa,
11+
from keepa.constants import DCODES, KEEPA_ST_ORDINAL, SCODES, csv_indices
12+
from keepa.keepa_async import AsyncKeepa
13+
from keepa.keepa_sync import Keepa
14+
from keepa.models.domain import Domain
15+
from keepa.models.product_params import ProductParams
16+
from keepa.plotting import plot_product
17+
from keepa.utils import (
1918
convert_offer_history,
20-
csv_indices,
2119
format_items,
2220
keepa_minutes_to_time,
2321
parse_csv,
2422
process_used_buybox,
2523
run_and_get,
2624
)
27-
from keepa.plotting import plot_product
2825

2926
__all__ = [
3027
"AsyncKeepa",

src/keepa/constants.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
"""Constants for Keepa API interactions."""
2+
3+
import numpy as np
4+
5+
# hardcoded ordinal time from
6+
KEEPA_ST_ORDINAL = np.datetime64("2011-01-01")
7+
8+
# Request limit
9+
REQUEST_LIMIT = 100
10+
11+
# Status code dictionary/key
12+
SCODES = {
13+
"400": "REQUEST_REJECTED",
14+
"402": "PAYMENT_REQUIRED",
15+
"405": "METHOD_NOT_ALLOWED",
16+
"429": "NOT_ENOUGH_TOKEN",
17+
}
18+
19+
# domain codes
20+
# Valid values: [ 1: com | 2: co.uk | 3: de | 4: fr | 5:
21+
# co.jp | 6: ca | 7: cn | 8: it | 9: es | 10: in | 11: com.mx | 12: com.br ]
22+
DCODES = [
23+
"RESERVED",
24+
"US",
25+
"GB",
26+
"DE",
27+
"FR",
28+
"JP",
29+
"CA",
30+
"CN",
31+
"IT",
32+
"ES",
33+
"IN",
34+
"MX",
35+
"BR",
36+
]
37+
# developer note: appears like CN (China) has changed to RESERVED2
38+
39+
# csv indices. used when parsing csv and stats fields.
40+
# https://github.com/keepacom/api_backend
41+
# see api_backend/src/main/java/com/keepa/api/backend/structs/Product.java
42+
# [index in csv, key name, isfloat(is price or rating)]
43+
csv_indices: list[tuple[int, str, bool]] = [
44+
(0, "AMAZON", True),
45+
(1, "NEW", True),
46+
(2, "USED", True),
47+
(3, "SALES", False),
48+
(4, "LISTPRICE", True),
49+
(5, "COLLECTIBLE", True),
50+
(6, "REFURBISHED", True),
51+
(7, "NEW_FBM_SHIPPING", True),
52+
(8, "LIGHTNING_DEAL", True),
53+
(9, "WAREHOUSE", True),
54+
(10, "NEW_FBA", True),
55+
(11, "COUNT_NEW", False),
56+
(12, "COUNT_USED", False),
57+
(13, "COUNT_REFURBISHED", False),
58+
(14, "CollectableOffers", False),
59+
(15, "EXTRA_INFO_UPDATES", False),
60+
(16, "RATING", True),
61+
(17, "COUNT_REVIEWS", False),
62+
(18, "BUY_BOX_SHIPPING", True),
63+
(19, "USED_NEW_SHIPPING", True),
64+
(20, "USED_VERY_GOOD_SHIPPING", True),
65+
(21, "USED_GOOD_SHIPPING", True),
66+
(22, "USED_ACCEPTABLE_SHIPPING", True),
67+
(23, "COLLECTIBLE_NEW_SHIPPING", True),
68+
(24, "COLLECTIBLE_VERY_GOOD_SHIPPING", True),
69+
(25, "COLLECTIBLE_GOOD_SHIPPING", True),
70+
(26, "COLLECTIBLE_ACCEPTABLE_SHIPPING", True),
71+
(27, "REFURBISHED_SHIPPING", True),
72+
(28, "EBAY_NEW_SHIPPING", True),
73+
(29, "EBAY_USED_SHIPPING", True),
74+
(30, "TRADE_IN", True),
75+
(31, "RENT", False),
76+
]
77+
78+
_SELLER_TIME_DATA_KEYS = ["trackedSince", "lastUpdate"]

0 commit comments

Comments
 (0)