politefetch 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,49 @@
1
+ """politefetch: a polite, crash-safe gate between an ingest service and the
2
+ external sources it polls.
3
+
4
+ It keeps the source safe from the caller (one attempt per call, persistent
5
+ per-host promises and daily caps that survive restarts, freezing on 403/429/451)
6
+ and the caller safe from the source (truncated bodies, HTML instead of data,
7
+ data that stopped advancing). See SPEC.md for the rules.
8
+ """
9
+
10
+ from politefetch.clock import Clock, FakeClock, SystemClock
11
+ from politefetch.errors import (
12
+ BodyTooLarge,
13
+ ContentError,
14
+ FetchFailed,
15
+ NoPolicy,
16
+ OutcomeNotSaved,
17
+ PoliteFetchError,
18
+ RefusalReason,
19
+ Refused,
20
+ SourceNotReady,
21
+ StaleData,
22
+ StuckSource,
23
+ UnexpectedContent,
24
+ )
25
+ from politefetch.gate import Gate
26
+ from politefetch.policy import HostPolicy
27
+
28
+ __version__ = "0.1.0"
29
+
30
+ __all__ = [
31
+ "BodyTooLarge",
32
+ "Clock",
33
+ "ContentError",
34
+ "FakeClock",
35
+ "FetchFailed",
36
+ "Gate",
37
+ "HostPolicy",
38
+ "NoPolicy",
39
+ "OutcomeNotSaved",
40
+ "PoliteFetchError",
41
+ "RefusalReason",
42
+ "Refused",
43
+ "SourceNotReady",
44
+ "StaleData",
45
+ "StuckSource",
46
+ "SystemClock",
47
+ "UnexpectedContent",
48
+ "__version__",
49
+ ]
@@ -0,0 +1,15 @@
1
+ """Transport adapters: they run the HTTP request the gate allowed and record
2
+ the shape of any failure (connect timeout, reset, refusal, TLS, HTTP status)
3
+ the same way whatever the client. The core never imports an HTTP client.
4
+
5
+ from politefetch.adapters.urllib import UrllibFetcher # no extras
6
+ from politefetch.adapters.httpx import HttpxFetcher # extra "httpx"
7
+ from politefetch.adapters.httpx import AsyncHttpxFetcher
8
+ from politefetch.adapters.requests import RequestsFetcher # extra "requests"
9
+
10
+ result = fetcher.get(url, expect="json", data_time=..., max_age="3h")
11
+ """
12
+
13
+ from politefetch.adapters.base import AsyncFetcher, FailureShape, Fetcher, FetchResult
14
+
15
+ __all__ = ["AsyncFetcher", "FailureShape", "FetchResult", "Fetcher"]