mm-std 0.3.7__py3-none-any.whl → 0.3.9__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/config.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import sys
2
2
  import tomllib
3
3
  from pathlib import Path
4
- from typing import NoReturn
4
+ from typing import NoReturn, Self
5
5
 
6
6
  from pydantic import BaseModel, ConfigDict, ValidationError
7
7
 
@@ -35,7 +35,7 @@ class BaseConfig(BaseModel):
35
35
  sys.exit(1)
36
36
 
37
37
  @classmethod
38
- def read_toml_config[T](cls: type[T], config_path: Path, zip_password: str = "") -> Result[T]: # nosec
38
+ def read_toml_config(cls, config_path: Path, zip_password: str = "") -> Result[Self]: # nosec
39
39
  try:
40
40
  config_path = config_path.expanduser()
41
41
  if config_path.name.endswith(".zip"):
mm_std/dict.py CHANGED
@@ -2,35 +2,14 @@ def replace_empty_dict_values(
2
2
  data: dict[object, object],
3
3
  defaults: dict[object, object] | None = None,
4
4
  zero_is_empty: bool = False,
5
+ false_is_empty: bool = False,
5
6
  ) -> dict[object, object]:
6
- """
7
- Replace empty values in a dictionary with provided default values, or remove them if no default exists.
8
-
9
- An "empty" value is defined as one of the following:
10
- - None
11
- - An empty string ("")
12
-
13
- If the flag `zero_is_empty` is True, the numeric value 0 is also considered empty.
14
-
15
- For each key in the input dictionary `data`, if its value is empty, the function checks the
16
- `defaults` dictionary for a replacement. If a default exists, it uses that value; otherwise, the
17
- key is omitted from the resulting dictionary.
18
-
19
- Parameters:
20
- data (dict[object, object]): The input dictionary with key-value pairs to process.
21
- defaults (dict[object, object] | None, optional): A dictionary of default values to use as
22
- replacements for empty entries. If None, no default replacements are applied.
23
- zero_is_empty (bool, optional): If True, treats the value 0 as empty. Defaults to False.
24
-
25
- Returns:
26
- dict[object, object]: A new dictionary with empty values replaced by defaults or removed if no
27
- default is provided.
28
- """
7
+ """Replace empty values in a dictionary with provided default values, or remove them if no default exists."""
29
8
  if defaults is None:
30
9
  defaults = {}
31
10
  result = {}
32
11
  for key, value in data.items():
33
- if value is None or value == "" or (zero_is_empty and value == 0):
12
+ if value is None or value == "" or (zero_is_empty and value == 0) or (false_is_empty and value is False):
34
13
  value = defaults.get(key, None) # noqa: PLW2901
35
14
  if value is not None:
36
15
  result[key] = value
mm_std/http_.py CHANGED
@@ -3,9 +3,9 @@ from dataclasses import asdict, dataclass, field
3
3
  from typing import Any
4
4
  from urllib.parse import urlencode
5
5
 
6
- import httpx
7
6
  import pydash
8
- from httpx._types import AuthTypes
7
+ import requests
8
+ from requests.auth import AuthBase
9
9
 
10
10
  from mm_std.result import Err, Ok, Result
11
11
 
@@ -90,7 +90,7 @@ def hrequest(
90
90
  timeout: float = 10,
91
91
  user_agent: str | None = None,
92
92
  json_params: bool = True,
93
- auth: AuthTypes | None = None,
93
+ auth: AuthBase | tuple[str, str] | None = None,
94
94
  verify: bool = True,
95
95
  ) -> HResponse:
96
96
  query_params: dict[str, Any] | None = None
@@ -108,11 +108,18 @@ def hrequest(
108
108
  else:
109
109
  data = params
110
110
 
111
+ proxies = None
112
+ if proxy:
113
+ proxies = {
114
+ "http": proxy,
115
+ "https": proxy,
116
+ }
117
+
111
118
  try:
112
- r = httpx.request(
119
+ r = requests.request(
113
120
  method,
114
121
  url,
115
- proxy=proxy,
122
+ proxies=proxies,
116
123
  timeout=timeout,
117
124
  cookies=cookies,
118
125
  auth=auth,
@@ -123,11 +130,11 @@ def hrequest(
123
130
  data=data,
124
131
  )
125
132
  return HResponse(code=r.status_code, body=r.text, headers=dict(r.headers))
126
- except httpx.TimeoutException:
133
+ except requests.exceptions.Timeout:
127
134
  return HResponse(error="timeout")
128
- except httpx.ProxyError:
135
+ except requests.exceptions.ProxyError:
129
136
  return HResponse(error="proxy_error")
130
- except httpx.HTTPError as err:
137
+ except requests.exceptions.RequestException as err:
131
138
  return HResponse(error=f"connection_error: {err}")
132
139
  except Exception as err:
133
140
  return HResponse(error=f"exception: {err}")
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mm-std
3
- Version: 0.3.7
3
+ Version: 0.3.9
4
4
  Requires-Python: >=3.12
5
5
  Requires-Dist: cryptography~=44.0.2
6
- Requires-Dist: httpx[http2,socks]~=0.28.1
7
6
  Requires-Dist: pydantic~=2.10.6
8
7
  Requires-Dist: pydash~=8.0.5
9
8
  Requires-Dist: python-dotenv~=1.0.1
9
+ Requires-Dist: requests[socks]~=2.32.3
10
10
  Requires-Dist: rich~=13.9.4
11
11
  Requires-Dist: tomlkit~=0.13.2
@@ -1,13 +1,13 @@
1
1
  mm_std/__init__.py,sha256=wzKZe6qMG7cmZLqnA-thfr4QaFaPudJzcQKqLsfZeB8,2500
2
2
  mm_std/command.py,sha256=ze286wjUjg0QSTgIu-2WZks53_Vclg69UaYYgPpQvCU,1283
3
3
  mm_std/concurrency.py,sha256=4kKLhde6YQYsjJJjH6K5eMQj6FtegEz55Mo5TmhQMM0,5242
4
- mm_std/config.py,sha256=4DGzjLO8TYno1xF8wj2hRaw2-gfNzt_W1_bt7w8ovno,1874
4
+ mm_std/config.py,sha256=4ox4D2CgGR76bvZ2n2vGQOYUDagFnlKEDb87to5zpxE,1871
5
5
  mm_std/crypto.py,sha256=jdk0_TCmeU0pPXMyz9xH6kQHSjjZ9GcGClBwQps5vBo,340
6
6
  mm_std/date.py,sha256=976eEkSONuNqHQBgSRu8hrtH23tJqztbmHFHLdbP2TY,1879
7
- mm_std/dict.py,sha256=E8YxRCs-hdXt0yhZUzR_o892LYokHzcFxSaGh835yjI,1588
7
+ mm_std/dict.py,sha256=6GkhJPXD0LiJDxPcYe6jPdEDw-MN7P7mKu6U5XxwYDk,675
8
8
  mm_std/env.py,sha256=5zaR9VeIfObN-4yfgxoFeU5IM1GDeZZj9SuYf7t9sOA,125
9
9
  mm_std/fs.py,sha256=RwarNRJq3tIMG6LVX_g03hasfYpjYFh_O27oVDt5IPQ,291
10
- mm_std/http_.py,sha256=QaPPXVb-rOS0BpoKdYQ0ABm_-mcR5dNa7Uqn-SeW_kE,4119
10
+ mm_std/http_.py,sha256=NkA98bCAqBmjJgoain0KZVORizGwH0TkbtYvjBEsrB4,4305
11
11
  mm_std/json_.py,sha256=Naa6mBE4D0yiQGkPNRrFvndnUH3R7ovw3FeaejWV60o,1196
12
12
  mm_std/log.py,sha256=6ux6njNKc_ZCQlvWn1FZR6vcSY2Cem-mQzmNXvsg5IE,913
13
13
  mm_std/net.py,sha256=qdRCBIDneip6FaPNe5mx31UtYVmzqam_AoUF7ydEyjA,590
@@ -19,6 +19,6 @@ mm_std/str.py,sha256=BEjJ1p5O4-uSYK0h-enasSSDdwzkBbiwdQ4_dsrlEE8,3257
19
19
  mm_std/toml.py,sha256=CNznWKR0bpOxS6e3VB5LGS-Oa9lW-wterkcPUFtPcls,610
20
20
  mm_std/types_.py,sha256=hvZlnvBWyB8CL_MeEWWD0Y0nN677plibYn3yD-5g7xs,99
21
21
  mm_std/zip.py,sha256=axzF1BwcIygtfNNTefZH7hXKaQqwe-ZH3ChuRWr9dnk,396
22
- mm_std-0.3.7.dist-info/METADATA,sha256=Fy4PKSoAghLXCIQa8zJMIeO64q3GFRuYucv9XDlz360,308
23
- mm_std-0.3.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
- mm_std-0.3.7.dist-info/RECORD,,
22
+ mm_std-0.3.9.dist-info/METADATA,sha256=QqBM2hxSUenibV7VnHSuu0QHn5eVoKOPGClxbmfklEI,305
23
+ mm_std-0.3.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
+ mm_std-0.3.9.dist-info/RECORD,,
File without changes