alterlab 2.3.0__tar.gz → 2.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {alterlab-2.3.0 → alterlab-2.4.2}/PKG-INFO +2 -1
- {alterlab-2.3.0 → alterlab-2.4.2}/alterlab/__init__.py +38 -1
- alterlab-2.4.2/alterlab/_failure_backoff.py +30 -0
- alterlab-2.4.2/alterlab/actions.py +743 -0
- {alterlab-2.3.0 → alterlab-2.4.2}/alterlab/client.py +1091 -491
- alterlab-2.4.2/alterlab/document_types.py +175 -0
- alterlab-2.4.2/alterlab/requests_compat.py +337 -0
- {alterlab-2.3.0 → alterlab-2.4.2}/pyproject.toml +1 -1
- {alterlab-2.3.0 → alterlab-2.4.2}/alterlab/crypto.py +0 -0
- {alterlab-2.3.0 → alterlab-2.4.2}/alterlab/resources/__init__.py +0 -0
- {alterlab-2.3.0 → alterlab-2.4.2}/alterlab/resources/sessions.py +0 -0
- {alterlab-2.3.0 → alterlab-2.4.2}/alterlab/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: alterlab
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.2
|
|
4
4
|
Summary: AlterLab Python SDK
|
|
5
5
|
Author: AlterLab
|
|
6
6
|
Author-email: dev@alterlab.io
|
|
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
17
|
Requires-Dist: httpx (>=0.25.2,<0.26.0)
|
|
17
18
|
Requires-Dist: pydantic (>=2.5.0,<3.0.0)
|
|
18
19
|
Requires-Dist: typing_extensions (>=3.7.4)
|
|
@@ -33,8 +33,17 @@ For synchronous usage:
|
|
|
33
33
|
with AlterLabSync(api_key="sk_test_...") as client:
|
|
34
34
|
result = client.scrape("https://example.com")
|
|
35
35
|
print(result['content'])
|
|
36
|
+
|
|
37
|
+
For a drop-in ``requests`` replacement (zero setup beyond an env var):
|
|
38
|
+
from alterlab import requests
|
|
39
|
+
|
|
40
|
+
response = requests.get("https://example.com")
|
|
41
|
+
print(response.status_code, response.text)
|
|
36
42
|
"""
|
|
37
43
|
|
|
44
|
+
from alterlab import actions as _actions
|
|
45
|
+
from alterlab import requests_compat as requests
|
|
46
|
+
from alterlab.actions import * # noqa: F401,F403 (names listed in actions.__all__)
|
|
38
47
|
from alterlab.client import (
|
|
39
48
|
AdvancedOptions,
|
|
40
49
|
AlterLab,
|
|
@@ -43,9 +52,23 @@ from alterlab.client import (
|
|
|
43
52
|
AlterLabSync,
|
|
44
53
|
AlterLabTimeoutError,
|
|
45
54
|
AlterLabValidationError,
|
|
55
|
+
AuthenticationError,
|
|
46
56
|
CostControls,
|
|
57
|
+
ForcedRenderHint,
|
|
58
|
+
InsufficientFundsError,
|
|
47
59
|
JobExpiredError,
|
|
60
|
+
JobFailedError,
|
|
61
|
+
RateLimitError,
|
|
62
|
+
get_error_hint,
|
|
63
|
+
)
|
|
64
|
+
from alterlab import document_types
|
|
65
|
+
from alterlab.document_types import (
|
|
66
|
+
DocumentBlock,
|
|
67
|
+
DocumentLink,
|
|
68
|
+
DocumentMedia,
|
|
69
|
+
DocumentV1,
|
|
48
70
|
)
|
|
71
|
+
from alterlab.requests_compat import AlterLabHTTPError
|
|
49
72
|
from alterlab.types import (
|
|
50
73
|
ContentImage,
|
|
51
74
|
ContentLink,
|
|
@@ -56,7 +79,7 @@ from alterlab.types import (
|
|
|
56
79
|
SessionValidation,
|
|
57
80
|
)
|
|
58
81
|
|
|
59
|
-
__version__ = "2.2
|
|
82
|
+
__version__ = "2.4.2"
|
|
60
83
|
__all__ = [
|
|
61
84
|
"AlterLab",
|
|
62
85
|
"AlterLabSync",
|
|
@@ -64,9 +87,16 @@ __all__ = [
|
|
|
64
87
|
"CostControls",
|
|
65
88
|
"AlterLabError",
|
|
66
89
|
"AlterLabAPIError",
|
|
90
|
+
"AlterLabHTTPError",
|
|
67
91
|
"AlterLabTimeoutError",
|
|
68
92
|
"AlterLabValidationError",
|
|
93
|
+
"AuthenticationError",
|
|
94
|
+
"InsufficientFundsError",
|
|
95
|
+
"RateLimitError",
|
|
69
96
|
"JobExpiredError",
|
|
97
|
+
"JobFailedError",
|
|
98
|
+
"ForcedRenderHint",
|
|
99
|
+
"get_error_hint",
|
|
70
100
|
"SessionIntegration",
|
|
71
101
|
"SessionListResponse",
|
|
72
102
|
"SessionValidation",
|
|
@@ -74,4 +104,11 @@ __all__ = [
|
|
|
74
104
|
"ContentImage",
|
|
75
105
|
"ContentLink",
|
|
76
106
|
"ExtractionMetadata",
|
|
107
|
+
"document_types",
|
|
108
|
+
"DocumentV1",
|
|
109
|
+
"DocumentBlock",
|
|
110
|
+
"DocumentLink",
|
|
111
|
+
"DocumentMedia",
|
|
112
|
+
"requests",
|
|
77
113
|
]
|
|
114
|
+
__all__ += _actions.__all__
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Parsing for the repeat-failure back-off 429 (``error: "repeat_failure_backoff"``).
|
|
2
|
+
|
|
3
|
+
The API returns this uncharged 429 when the same request failed the same way
|
|
4
|
+
several times in a row. Its ``detail`` extends the canonical rate-limit detail
|
|
5
|
+
with ``consecutive_failures``, ``outcome_class``, ``failure_code`` and ``hint``.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Any, Optional, Tuple
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def parse_failure_backoff_detail(
|
|
12
|
+
detail: Any,
|
|
13
|
+
) -> Tuple[Optional[int], Optional[str], Optional[str]]:
|
|
14
|
+
"""Return ``(consecutive_failures, outcome_class, failure_code)`` from ``detail``.
|
|
15
|
+
|
|
16
|
+
Each value is ``None`` when ``detail`` is not a dict or the field is
|
|
17
|
+
missing or of the wrong type.
|
|
18
|
+
"""
|
|
19
|
+
if not isinstance(detail, dict):
|
|
20
|
+
return None, None, None
|
|
21
|
+
count = detail.get("consecutive_failures")
|
|
22
|
+
if not isinstance(count, int) or isinstance(count, bool):
|
|
23
|
+
count = None
|
|
24
|
+
outcome_class = detail.get("outcome_class")
|
|
25
|
+
if not isinstance(outcome_class, str):
|
|
26
|
+
outcome_class = None
|
|
27
|
+
failure_code = detail.get("failure_code")
|
|
28
|
+
if not isinstance(failure_code, str):
|
|
29
|
+
failure_code = None
|
|
30
|
+
return count, outcome_class, failure_code
|