native-dumper 0.3.5.2__cp313-cp313-win_amd64.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,264 @@
1
+ from typing import Iterable
2
+
3
+
4
+ class HttpResponse:
5
+ """HttpResponse with fileobject methods."""
6
+
7
+ def __init__(self) -> None:
8
+ """Class initialization."""
9
+
10
+ ...
11
+
12
+ def read(
13
+ self,
14
+ size: int | None = None,
15
+ ) -> bytes:
16
+ """Read data from the HTTP response.
17
+
18
+ Args:
19
+ size: Number of bytes to read.
20
+ If None or not specified, reads all available data.
21
+
22
+ Returns:
23
+ Bytes read from the response.
24
+ """
25
+
26
+ ...
27
+
28
+ def read1(self) -> bytes:
29
+ """Read a single byte from the HTTP response.
30
+
31
+ Returns:
32
+ Single byte as bytes object.
33
+ """
34
+
35
+ ...
36
+
37
+ def get_status(self) -> int | None:
38
+ """Get the HTTP status code.
39
+
40
+ Returns:
41
+ HTTP status code or None if not available.
42
+ """
43
+
44
+ ...
45
+
46
+ def get_headers(self) -> dict[str, str] | None:
47
+ """Get all response headers.
48
+
49
+ Returns:
50
+ Dictionary of header names (lowercase)
51
+ to values, or None if not available.
52
+ """
53
+
54
+ ...
55
+
56
+ def get_header(self, name: str) -> str | None:
57
+ """Get a specific response header.
58
+
59
+ Args:
60
+ name: Header name (case-insensitive).
61
+
62
+ Returns:
63
+ Header value or None if header doesn't exist.
64
+ """
65
+
66
+ ...
67
+
68
+ def get_content_length(self) -> int | None:
69
+ """Get the content length from response headers.
70
+
71
+ Returns:
72
+ Content length in bytes or None if not specified.
73
+ """
74
+
75
+ ...
76
+
77
+ def is_success(self) -> bool:
78
+ """Check if the response indicates success (2xx status code).
79
+
80
+ Returns:
81
+ True if status code is in 200-299 range.
82
+ """
83
+
84
+ ...
85
+
86
+ def is_redirect(self) -> bool:
87
+ """Check if the response indicates a redirect (3xx status code).
88
+
89
+ Returns:
90
+ True if status code is in 300-399 range.
91
+ """
92
+
93
+ ...
94
+
95
+ def is_client_error(self) -> bool:
96
+ """Check if the response indicates a client error (4xx status code).
97
+
98
+ Returns:
99
+ True if status code is in 400-499 range.
100
+ """
101
+
102
+ ...
103
+
104
+ def is_server_error(self) -> bool:
105
+ """Check if the response indicates a server error (5xx status code).
106
+
107
+ Returns:
108
+ True if status code is in 500-599 range.
109
+ """
110
+
111
+ ...
112
+
113
+ def get_content_type(self) -> str | None:
114
+ """Get the Content-Type header value.
115
+
116
+ Returns:
117
+ Content-Type value or None if not specified.
118
+ """
119
+
120
+ ...
121
+
122
+ def get_url(self) -> str | None:
123
+ """Get the final URL of the response (after redirects).
124
+
125
+ Returns:
126
+ URL string or None if not available.
127
+ """
128
+
129
+ ...
130
+
131
+ def seek(self, pos: int) -> None:
132
+ """Seek to a position in the response stream.
133
+
134
+ Args:
135
+ pos: Position to seek to (only position 0 is supported).
136
+
137
+ Raises:
138
+ IOError: If seeking is not allowed or position is not 0.
139
+ """
140
+
141
+ ...
142
+
143
+ def seekable(self) -> bool:
144
+ """Check if the response stream supports seeking.
145
+
146
+ Returns:
147
+ True if seeking to position 0 is allowed.
148
+ """
149
+
150
+ ...
151
+
152
+ def close(self) -> None:
153
+ """Close the response and release resources."""
154
+
155
+ ...
156
+
157
+ def is_closed(self) -> bool:
158
+ """Check if the response is closed.
159
+
160
+ Returns:
161
+ True if response is closed.
162
+ """
163
+
164
+ ...
165
+
166
+ def get_info(self) -> dict[str, str]:
167
+ """Get comprehensive information about the response.
168
+
169
+ Returns:
170
+ Dictionary containing response metadata.
171
+ """
172
+
173
+ ...
174
+
175
+ def tell(self) -> int:
176
+ """Get the current read position in the response stream.
177
+
178
+ Returns:
179
+ Current position in bytes.
180
+ """
181
+
182
+ ...
183
+
184
+
185
+ class HttpSession:
186
+ """HttpSession with post method only."""
187
+
188
+ def __init__(
189
+ self,
190
+ timeout: float | int | None,
191
+ ) -> None:
192
+ """Initialize an HTTP session.
193
+
194
+ Args:
195
+ timeout: Request timeout in seconds. Default is 30 seconds.
196
+
197
+ Raises:
198
+ RuntimeError: If HTTP client creation fails.
199
+ """
200
+
201
+ ...
202
+
203
+ def post(
204
+ self,
205
+ url: str,
206
+ headers: dict[str, str] | None,
207
+ params: dict[str, str] | None,
208
+ data: bytes | Iterable[bytes | bytearray] | None,
209
+ timeout: float | int | None,
210
+ ) -> HttpResponse:
211
+ """Send a POST request.
212
+
213
+ Args:
214
+ url: Target URL.
215
+ headers: HTTP headers as key-value pairs.
216
+ params: URL parameters as key-value pairs.
217
+ data: Request body data. Can be:
218
+ - bytes
219
+ - list of bytes objects
220
+ - byte array
221
+ - iterable/generator yielding bytes
222
+ timeout: Request timeout in seconds (overrides session timeout).
223
+
224
+ Returns:
225
+ HttpResponse object.
226
+
227
+ Raises:
228
+ IOError: If HTTP request fails.
229
+ TypeError: If data type is not supported.
230
+ """
231
+
232
+ ...
233
+
234
+ def post_stream(
235
+ self,
236
+ url: str,
237
+ headers: dict[str, str] | None,
238
+ params: dict[str, str] | None,
239
+ data: bytes | Iterable[bytes | bytearray] | None,
240
+ timeout: float | int | None,
241
+ ) -> HttpResponse:
242
+ """Send a POST request (alias for post method).
243
+
244
+ Args:
245
+ url: Target URL.
246
+ headers: HTTP headers as key-value pairs.
247
+ params: URL parameters as key-value pairs.
248
+ data: Request body data.
249
+ timeout: Request timeout in seconds.
250
+
251
+ Returns:
252
+ HttpResponse object.
253
+ """
254
+
255
+ ...
256
+
257
+ def close(self) -> None:
258
+ """Close the HTTP session and release resources.
259
+
260
+ This method should be called when the session is no longer needed
261
+ to properly clean up connections and resources.
262
+ """
263
+
264
+ ...
@@ -0,0 +1,11 @@
1
+ from collections.abc import Generator
2
+ from io import BufferedReader
3
+
4
+ from .defines import CHUNK_SIZE
5
+
6
+
7
+ def file_writer(fileobj: BufferedReader) -> Generator[bytes, None, None]:
8
+ """Chunk fileobj to bytes generator."""
9
+
10
+ while chunk := fileobj.read(CHUNK_SIZE):
11
+ yield chunk