python-http_request 0.0.4__tar.gz → 0.0.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-http_request
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: Python http response utils.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-http_request
6
6
  License: MIT
@@ -23,7 +23,8 @@ Classifier: Topic :: Software Development :: Libraries
23
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
24
  Requires-Dist: integer_tool
25
25
  Requires-Dist: python-asynctools
26
- Requires-Dist: python-filewrap
26
+ Requires-Dist: python-filewrap (>=0.1)
27
+ Requires-Dist: python-texttools
27
28
  Project-URL: Repository, https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-http_request
28
29
  Description-Content-Type: text/markdown
29
30
 
@@ -2,7 +2,7 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  __author__ = "ChenyangGao <https://chenyanggao.github.io>"
5
- __version__ = (0, 0, 4)
5
+ __version__ = (0, 0, 5)
6
6
  __all__ = [
7
7
  "SupportsGeturl", "url_origin", "complete_url", "cookies_str_to_dict", "headers_str_to_dict",
8
8
  "encode_multipart_data", "encode_multipart_data_async",
@@ -16,7 +16,7 @@ from urllib.parse import quote, urlsplit, urlunsplit
16
16
  from uuid import uuid4
17
17
 
18
18
  from asynctools import ensure_aiter, async_chain
19
- from filewrap import bio_chunk_iter, bio_chunk_async_iter, SupportsRead
19
+ from filewrap import bio_chunk_iter, bio_chunk_async_iter, Buffer, SupportsRead
20
20
  from integer_tool import int_to_bytes
21
21
  from texttools import text_to_dict
22
22
 
@@ -73,8 +73,8 @@ def headers_str_to_dict(
73
73
  return text_to_dict(headers.strip(), kv_sep, entry_sep)
74
74
 
75
75
 
76
- def ensure_bytes(s, /) -> bytes | bytearray | memoryview:
77
- if isinstance(s, (bytes, bytearray, memoryview)):
76
+ def ensure_bytes(s, /) -> Buffer:
77
+ if isinstance(s, Buffer):
78
78
  return s
79
79
  if isinstance(s, int):
80
80
  return int_to_bytes(s)
@@ -88,16 +88,14 @@ def ensure_bytes(s, /) -> bytes | bytearray | memoryview:
88
88
 
89
89
  def encode_multipart_data(
90
90
  data: Mapping[str, Any],
91
- files: Mapping[str, bytes | bytearray | memoryview |
92
- SupportsRead[bytes] | SupportsRead[bytearray] | SupportsRead[memoryview] |
93
- Iterable[bytes] | Iterable[bytearray] | Iterable[memoryview]],
91
+ files: Mapping[str, Buffer | SupportsRead[Buffer] | Iterable[Buffer]],
94
92
  boundary: None | str = None,
95
- ) -> tuple[dict, Iterator[bytes | bytearray | memoryview]]:
93
+ ) -> tuple[dict, Iterator[Buffer]]:
96
94
  if not boundary:
97
95
  boundary = uuid4().bytes.hex()
98
96
  headers = {"Content-Type": f"multipart/form-data; boundary={boundary}"}
99
97
 
100
- def encode_data(data) -> Iterator[bytes | bytearray | memoryview]:
98
+ def encode_data(data) -> Iterator[Buffer]:
101
99
  if isinstance(data, Mapping):
102
100
  data = ItemsView(data)
103
101
  for name, value in data:
@@ -106,7 +104,7 @@ def encode_multipart_data(
106
104
  yield ensure_bytes(value)
107
105
  yield b"\r\n"
108
106
 
109
- def encode_files(files) -> Iterator[bytes | bytearray | memoryview]:
107
+ def encode_files(files) -> Iterator[Buffer]:
110
108
  if isinstance(files, Mapping):
111
109
  files = ItemsView(files)
112
110
  for name, file in files:
@@ -126,17 +124,14 @@ def encode_multipart_data(
126
124
 
127
125
  def encode_multipart_data_async(
128
126
  data: Mapping[str, Any],
129
- files: Mapping[str, bytes | bytearray | memoryview |
130
- SupportsRead[bytes] | SupportsRead[bytearray] | SupportsRead[memoryview] |
131
- Iterable[bytes] | Iterable[bytearray] | Iterable[memoryview] |
132
- AsyncIterable[bytes] | AsyncIterable[bytearray] | AsyncIterable[memoryview]],
127
+ files: Mapping[str, Buffer | SupportsRead[Buffer] | Iterable[Buffer] | AsyncIterable[Buffer]],
133
128
  boundary: None | str = None,
134
- ) -> tuple[dict, AsyncIterator[bytes | bytearray | memoryview]]:
129
+ ) -> tuple[dict, AsyncIterator[Buffer]]:
135
130
  if not boundary:
136
131
  boundary = uuid4().bytes.hex()
137
132
  headers = {"Content-Type": f"multipart/form-data; boundary={boundary}"}
138
133
 
139
- async def encode_data(data) -> AsyncIterator[bytes | bytearray | memoryview]:
134
+ async def encode_data(data) -> AsyncIterator[Buffer]:
140
135
  if isinstance(data, Mapping):
141
136
  data = ItemsView(data)
142
137
  for name, value in data:
@@ -145,7 +140,7 @@ def encode_multipart_data_async(
145
140
  yield ensure_bytes(value)
146
141
  yield b"\r\n"
147
142
 
148
- async def encode_files(files) -> AsyncIterator[bytes | bytearray | memoryview]:
143
+ async def encode_files(files) -> AsyncIterator[Buffer]:
149
144
  if isinstance(files, Mapping):
150
145
  files = ItemsView(files)
151
146
  for name, file in files:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-http_request"
3
- version = "0.0.4"
3
+ version = "0.0.5"
4
4
  description = "Python http response utils."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"
@@ -28,7 +28,8 @@ include = [
28
28
  [tool.poetry.dependencies]
29
29
  python = "^3.10"
30
30
  python-asynctools = "*"
31
- python-filewrap = "*"
31
+ python-filewrap = ">=0.1"
32
+ python-texttools = "*"
32
33
  integer_tool = "*"
33
34
 
34
35
  [build-system]