mm-std 0.1.1__py3-none-any.whl → 0.1.2__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.
mm_std/net.py CHANGED
@@ -6,8 +6,8 @@ from json import JSONDecodeError
6
6
  from typing import Any, TypeVar, cast
7
7
  from urllib.parse import urlencode
8
8
 
9
+ import httpx
9
10
  import pydash
10
- import requests
11
11
 
12
12
  from mm_std.result import Err, Ok, Result
13
13
 
@@ -93,33 +93,41 @@ def hrequest(
93
93
  auth: Any = None,
94
94
  verify: bool = True,
95
95
  ) -> HResponse:
96
+ query_params: dict[str, Any] | None = None
97
+ data: dict[str, Any] | None = None
98
+ json_: dict[str, Any] | None = None
96
99
  method = method.upper()
97
- proxies = {"http": proxy, "https": proxy} if proxy else None
98
100
  if not headers:
99
101
  headers = {}
100
- try:
102
+ if user_agent:
101
103
  headers["user-agent"] = user_agent
102
- request_params = {
103
- "proxies": proxies,
104
- "timeout": timeout,
105
- "headers": headers,
106
- "cookies": cookies,
107
- "auth": auth,
108
- "verify": verify,
109
- }
110
- if method == "GET":
111
- request_params["params"] = params
112
- elif json_params:
113
- request_params["json"] = params
114
- else:
115
- request_params["data"] = params
116
- r = requests.request(method, url, **request_params)
104
+ if method == "GET":
105
+ query_params = params
106
+ elif json_params:
107
+ json_ = params
108
+ else:
109
+ data = params
110
+
111
+ try:
112
+ r = httpx.request(
113
+ method,
114
+ url,
115
+ proxy=proxy,
116
+ timeout=timeout,
117
+ cookies=cookies,
118
+ auth=auth,
119
+ verify=verify,
120
+ headers=headers,
121
+ params=query_params,
122
+ json=json_,
123
+ data=data,
124
+ )
117
125
  return HResponse(code=r.status_code, body=r.text, headers=dict(r.headers))
118
- except requests.exceptions.Timeout:
126
+ except httpx.TimeoutException:
119
127
  return HResponse(error="timeout")
120
- except requests.exceptions.ProxyError:
128
+ except httpx.ProxyError:
121
129
  return HResponse(error="proxy_error")
122
- except requests.exceptions.ConnectionError as err:
130
+ except httpx.HTTPError as err:
123
131
  return HResponse(error=f"connection_error: {err}")
124
132
  except Exception as err:
125
133
  return HResponse(error=f"exception: {err}")
@@ -1,13 +1,12 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mm-std
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Requires-Python: >=3.12
5
5
  Requires-Dist: cryptography~=43.0.1
6
- Requires-Dist: pydantic~=2.9.0
6
+ Requires-Dist: httpx[http2,socks]~=0.27.2
7
+ Requires-Dist: pydantic~=2.9.1
7
8
  Requires-Dist: pydash~=8.0.0
8
- Requires-Dist: pysocks~=1.7.1
9
9
  Requires-Dist: python-dateutil~=2.9.0
10
10
  Requires-Dist: python-dotenv~=1.0.1
11
11
  Requires-Dist: pyyaml~=6.0.1
12
- Requires-Dist: requests~=2.32.3
13
12
  Requires-Dist: rich
@@ -9,7 +9,7 @@ mm_std/env.py,sha256=5zaR9VeIfObN-4yfgxoFeU5IM1GDeZZj9SuYf7t9sOA,125
9
9
  mm_std/fs.py,sha256=RwarNRJq3tIMG6LVX_g03hasfYpjYFh_O27oVDt5IPQ,291
10
10
  mm_std/json_.py,sha256=12uGLwmnrRA63QI0nUx-UU33zXcyShbsKCoOQiIJ8io,1016
11
11
  mm_std/log.py,sha256=6ux6njNKc_ZCQlvWn1FZR6vcSY2Cem-mQzmNXvsg5IE,913
12
- mm_std/net.py,sha256=-xt2tEov3vhXR44Rlj4JohL-g1n7k7JUobo4kHTubzg,4702
12
+ mm_std/net.py,sha256=FIH_drMlf_ng-icI2w_mXiVyiLQUvJkskh3rQF8x8pM,4705
13
13
  mm_std/print_.py,sha256=mMixwfdrLEYW15ez7_QxXdrV-d38q9XJP8tB8F7P2pI,1553
14
14
  mm_std/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  mm_std/random_.py,sha256=KZauQzHsJaCVIeyHrJ74hiH34hdFE7pUxuv5i0Hl28g,1175
@@ -18,6 +18,6 @@ mm_std/str.py,sha256=nG5XF5870xM2PAvU0LZrJDk-d54LYwRLGnSahIekOVw,3151
18
18
  mm_std/telegram.py,sha256=QrHPnsy0LTeqpd-g3RaHhk7gWIfHZEgnMs-S5DLW-vU,1220
19
19
  mm_std/types.py,sha256=KpFtJ-BTmDfmmFeOSlgq6cMbCfGGOQjh1oWvdcrW-kw,116
20
20
  mm_std/zip.py,sha256=2EXcae4HO5U4kObj2Lj8jl5F2OUpT-WRlJybTyFzt6I,370
21
- mm_std-0.1.1.dist-info/METADATA,sha256=XuhpNkngXbk3lnhxGdXwKQet1lx86d9XuMaKXVP4fy8,355
22
- mm_std-0.1.1.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
23
- mm_std-0.1.1.dist-info/RECORD,,
21
+ mm_std-0.1.2.dist-info/METADATA,sha256=RmNcgip4Asdyy-AgtdiPkJ9tv6vxg3qcBc9zcz8wYqE,335
22
+ mm_std-0.1.2.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
23
+ mm_std-0.1.2.dist-info/RECORD,,
File without changes