fmtr.tools 1.2.5__py3-none-any.whl → 1.2.6__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.

Potentially problematic release.


This version of fmtr.tools might be problematic. Click here for more details.

@@ -1,4 +1,5 @@
1
1
  import dns
2
+ from dataclasses import dataclass
2
3
  from dns import query
3
4
  from functools import cached_property
4
5
  from httpx_retries import Retry, RetryTransport
@@ -39,6 +40,7 @@ class ClientBasePlain:
39
40
  exchange.response_upstream = Response.from_message(response)
40
41
 
41
42
 
43
+ @dataclass
42
44
  class ClientDoH:
43
45
  """
44
46
 
@@ -47,19 +49,19 @@ class ClientDoH:
47
49
  """
48
50
 
49
51
  HEADERS = {"Content-Type": "application/dns-message"}
50
- client = HTTPClientDoH()
52
+ CLIENT = HTTPClientDoH()
53
+ BOOTSTRAP = ClientBasePlain('8.8.8.8')
54
+
55
+ host: str
56
+ url: str
51
57
 
52
- def __init__(self, host, url):
53
- self.host = host
54
- self.url = url
55
- self.bootstrap = ClientBasePlain('8.8.8.8')
56
58
 
57
59
  @cached_property
58
60
  def ip(self):
59
61
  message = dns.message.make_query(self.host, dns.rdatatype.A, flags=0)
60
62
  request = Request.from_message(message)
61
63
  exchange = Exchange(request=request, ip=None, port=None)
62
- self.bootstrap.resolve(exchange)
64
+ self.BOOTSTRAP.resolve(exchange)
63
65
  ip = next(iter(exchange.response_upstream.answer.items.keys())).address
64
66
  return ip
65
67
 
@@ -72,7 +74,7 @@ class ClientDoH:
72
74
  request = exchange.request
73
75
  headers = self.HEADERS | dict(Host=self.host)
74
76
  url = self.url.format(host=self.ip)
75
- response_doh = self.client.post(url, headers=headers, content=request.wire)
77
+ response_doh = self.CLIENT.post(url, headers=headers, content=request.wire)
76
78
  response_doh.raise_for_status()
77
79
  response = Response.from_http(response_doh)
78
80
  exchange.response_upstream = response
@@ -1,10 +1,12 @@
1
1
  import socket
2
+ from dataclasses import dataclass
2
3
 
3
4
  from fmtr.tools import logger
4
5
  from fmtr.tools.dns_tools.client import ClientDoH
5
- from fmtr.tools.dns_tools.dm import Exchange, Response
6
+ from fmtr.tools.dns_tools.dm import Exchange
6
7
 
7
8
 
9
+ @dataclass
8
10
  class ServerBasePlain:
9
11
  """
10
12
 
@@ -12,9 +14,11 @@ class ServerBasePlain:
12
14
 
13
15
  """
14
16
 
15
- def __init__(self, host, port):
16
- self.host = host
17
- self.port = port
17
+ host: str
18
+ port: int
19
+
20
+ def __post_init__(self):
21
+
18
22
  self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
19
23
 
20
24
  def resolve(self, exchange: Exchange):
@@ -36,6 +40,7 @@ class ServerBasePlain:
36
40
  sock.sendto(exchange.response.wire, (ip, port))
37
41
 
38
42
 
43
+ @dataclass
39
44
  class ServerBaseDoHProxy(ServerBasePlain):
40
45
  """
41
46
 
@@ -43,9 +48,7 @@ class ServerBaseDoHProxy(ServerBasePlain):
43
48
 
44
49
  """
45
50
 
46
- def __init__(self, host, port, client: ClientDoH):
47
- super().__init__(host, port)
48
- self.client = client
51
+ client: ClientDoH
49
52
 
50
53
  def process_question(self, exchange: Exchange):
51
54
  return
@@ -53,16 +56,6 @@ class ServerBaseDoHProxy(ServerBasePlain):
53
56
  def process_upstream(self, exchange: Exchange):
54
57
  return
55
58
 
56
- def from_upstream(self, exchange: Exchange) -> Exchange:
57
-
58
- request = exchange.request
59
- response_doh = self.client.post(self.URL, headers=self.HEADERS, content=request.wire)
60
- response_doh.raise_for_status()
61
- response = Response.from_http(response_doh)
62
- exchange.response_upstream = response
63
-
64
- return exchange
65
-
66
59
  def resolve(self, exchange: Exchange):
67
60
  """
68
61
 
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.2.5
1
+ 1.2.6
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmtr.tools
3
- Version: 1.2.5
3
+ Version: 1.2.6
4
4
  Summary: Collection of high-level tools to simplify everyday development tasks, with a focus on AI/ML
5
5
  Home-page: https://github.com/fmtr/tools
6
6
  Author: Frontmatter
@@ -106,6 +106,8 @@ Requires-Dist: pydevd-pycharm; extra == "debug"
106
106
  Provides-Extra: sets
107
107
  Requires-Dist: pydantic-settings; extra == "sets"
108
108
  Requires-Dist: pydantic; extra == "sets"
109
+ Requires-Dist: yamlscript; extra == "sets"
110
+ Requires-Dist: pyyaml; extra == "sets"
109
111
  Provides-Extra: path-app
110
112
  Requires-Dist: appdirs; extra == "path-app"
111
113
  Provides-Extra: path-type
@@ -128,60 +130,60 @@ Requires-Dist: logfire[httpx]; extra == "http"
128
130
  Provides-Extra: setup
129
131
  Requires-Dist: setuptools; extra == "setup"
130
132
  Provides-Extra: all
133
+ Requires-Dist: uvicorn[standard]; extra == "all"
134
+ Requires-Dist: google-auth-httplib2; extra == "all"
135
+ Requires-Dist: html2text; extra == "all"
131
136
  Requires-Dist: distributed; extra == "all"
132
- Requires-Dist: pydevd-pycharm; extra == "all"
133
- Requires-Dist: ollama; extra == "all"
134
- Requires-Dist: sre_yield; extra == "all"
135
- Requires-Dist: flet-webview; extra == "all"
136
- Requires-Dist: dask[bag]; extra == "all"
137
- Requires-Dist: semver; extra == "all"
138
- Requires-Dist: diskcache; extra == "all"
139
137
  Requires-Dist: tabulate; extra == "all"
140
- Requires-Dist: bokeh; extra == "all"
141
- Requires-Dist: openai; extra == "all"
142
- Requires-Dist: pytest-cov; extra == "all"
143
- Requires-Dist: uvicorn[standard]; extra == "all"
144
- Requires-Dist: pyyaml; extra == "all"
145
- Requires-Dist: Unidecode; extra == "all"
146
- Requires-Dist: json_repair; extra == "all"
147
- Requires-Dist: google-auth-oauthlib; extra == "all"
148
- Requires-Dist: pymupdf4llm; extra == "all"
149
- Requires-Dist: google-auth; extra == "all"
138
+ Requires-Dist: pydantic; extra == "all"
139
+ Requires-Dist: openpyxl; extra == "all"
140
+ Requires-Dist: httpx; extra == "all"
141
+ Requires-Dist: tokenizers; extra == "all"
150
142
  Requires-Dist: fastapi; extra == "all"
151
- Requires-Dist: contexttimer; extra == "all"
152
- Requires-Dist: tinynetrc; extra == "all"
143
+ Requires-Dist: logfire; extra == "all"
144
+ Requires-Dist: ollama; extra == "all"
145
+ Requires-Dist: flet[all]; extra == "all"
146
+ Requires-Dist: flet-webview; extra == "all"
153
147
  Requires-Dist: flet-video; extra == "all"
154
- Requires-Dist: yamlscript; extra == "all"
155
- Requires-Dist: appdirs; extra == "all"
156
- Requires-Dist: logfire[httpx]; extra == "all"
157
- Requires-Dist: huggingface_hub; extra == "all"
158
- Requires-Dist: transformers[sentencepiece]; extra == "all"
159
148
  Requires-Dist: torchvision; extra == "all"
160
149
  Requires-Dist: httpx_retries; extra == "all"
161
- Requires-Dist: pymupdf; extra == "all"
150
+ Requires-Dist: tinynetrc; extra == "all"
162
151
  Requires-Dist: docker; extra == "all"
163
- Requires-Dist: regex; extra == "all"
164
- Requires-Dist: tokenizers; extra == "all"
165
- Requires-Dist: pydantic; extra == "all"
166
- Requires-Dist: logfire; extra == "all"
167
- Requires-Dist: filetype; extra == "all"
168
- Requires-Dist: logfire[fastapi]; extra == "all"
169
- Requires-Dist: html2text; extra == "all"
170
- Requires-Dist: flet[all]; extra == "all"
171
- Requires-Dist: torchaudio; extra == "all"
172
152
  Requires-Dist: setuptools; extra == "all"
173
- Requires-Dist: httpx; extra == "all"
174
- Requires-Dist: dnspython[doh]; extra == "all"
175
- Requires-Dist: deepmerge; extra == "all"
176
- Requires-Dist: google-auth-httplib2; extra == "all"
153
+ Requires-Dist: pytest-cov; extra == "all"
154
+ Requires-Dist: logfire[fastapi]; extra == "all"
155
+ Requires-Dist: transformers[sentencepiece]; extra == "all"
156
+ Requires-Dist: google-auth-oauthlib; extra == "all"
177
157
  Requires-Dist: sentence_transformers; extra == "all"
158
+ Requires-Dist: semver; extra == "all"
159
+ Requires-Dist: Unidecode; extra == "all"
160
+ Requires-Dist: faker; extra == "all"
161
+ Requires-Dist: sre_yield; extra == "all"
162
+ Requires-Dist: regex; extra == "all"
163
+ Requires-Dist: openai; extra == "all"
164
+ Requires-Dist: pymupdf; extra == "all"
165
+ Requires-Dist: yamlscript; extra == "all"
166
+ Requires-Dist: bokeh; extra == "all"
167
+ Requires-Dist: contexttimer; extra == "all"
168
+ Requires-Dist: json_repair; extra == "all"
178
169
  Requires-Dist: peft; extra == "all"
179
170
  Requires-Dist: google-api-python-client; extra == "all"
180
- Requires-Dist: openpyxl; extra == "all"
181
- Requires-Dist: faker; extra == "all"
171
+ Requires-Dist: deepmerge; extra == "all"
172
+ Requires-Dist: torchaudio; extra == "all"
173
+ Requires-Dist: google-auth; extra == "all"
174
+ Requires-Dist: pyyaml; extra == "all"
175
+ Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
176
+ Requires-Dist: appdirs; extra == "all"
177
+ Requires-Dist: huggingface_hub; extra == "all"
182
178
  Requires-Dist: pandas; extra == "all"
179
+ Requires-Dist: diskcache; extra == "all"
180
+ Requires-Dist: logfire[httpx]; extra == "all"
181
+ Requires-Dist: filetype; extra == "all"
182
+ Requires-Dist: pydevd-pycharm; extra == "all"
183
183
  Requires-Dist: pydantic-settings; extra == "all"
184
- Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
184
+ Requires-Dist: dask[bag]; extra == "all"
185
+ Requires-Dist: dnspython[doh]; extra == "all"
186
+ Requires-Dist: pymupdf4llm; extra == "all"
185
187
  Dynamic: author
186
188
  Dynamic: author-email
187
189
  Dynamic: description
@@ -44,16 +44,16 @@ fmtr/tools/tabular_tools.py,sha256=tpIpZzYku1HcJrHZJL6BC39LmN3WUWVhFbK2N7nDVmE,1
44
44
  fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
45
45
  fmtr/tools/tools.py,sha256=CAsApa1YwVdNE6H66Vjivs_mXYvOas3rh7fPELAnTpk,795
46
46
  fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
47
- fmtr/tools/version,sha256=Cl1xpTAk2dakEAYnido_4VW6RMyhUhB5H7iuCcdJQmw,5
47
+ fmtr/tools/version,sha256=PP3XZe61jmbow_ljgcG-wbwzB5i9ZhqLLvJeoEEgV60,5
48
48
  fmtr/tools/version_tools.py,sha256=yNs_CGqWpqE4jbK9wsPIi14peJVXYbhIcMqHAFOw3yE,1480
49
49
  fmtr/tools/yaml_tools.py,sha256=9kuYChqJelWQIjGlSnK4iDdOWWH06P0gp9jIcRrC3UI,1903
50
50
  fmtr/tools/ai_tools/__init__.py,sha256=JZrLuOFNV1A3wvJgonxOgz_4WS-7MfCuowGWA5uYCjs,372
51
51
  fmtr/tools/ai_tools/agentic_tools.py,sha256=acSEPFS-aguDXanWGs3fAAlRyJSYPZW7L-Kb2qDLm-I,4300
52
52
  fmtr/tools/ai_tools/inference_tools.py,sha256=2UP2gXEyOJUjyyV6zmFIYmIxUsh1rXkRH0IbFvr2bRs,11908
53
53
  fmtr/tools/dns_tools/__init__.py,sha256=PwHxnpiy6_isQfUmz_5V1hL0dcPaA6ItqvoGWW8MOfk,222
54
- fmtr/tools/dns_tools/client.py,sha256=zYMUc63iFRSPtCnhqx_nvsHHf-VQrLt3Vor0qxImfLs,2390
54
+ fmtr/tools/dns_tools/client.py,sha256=omHdk9bA_8u2-VMQhh0c9r9e-oG4mZ0MWA9lfbtSEIc,2371
55
55
  fmtr/tools/dns_tools/dm.py,sha256=mvXacq6QJ86G0S0tkzJFhU7bOaSJytvsMNlxs5X9hfE,2236
56
- fmtr/tools/dns_tools/server.py,sha256=8oGCJZ-xTJhJ0gq21ro8Z0ZpfRYIdoWy7bLm9LOQcU0,2764
56
+ fmtr/tools/dns_tools/server.py,sha256=hSZhK4EZD6Ox4uRI3ldbnyyZf6DYgMUcTfffbrZN5pk,2329
57
57
  fmtr/tools/entrypoints/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
58
  fmtr/tools/entrypoints/cache_hfh.py,sha256=fQNs4J9twQuZH_Yj98-oOvEX7-LrSUP3kO8nzw2HrHs,60
59
59
  fmtr/tools/entrypoints/ep_test.py,sha256=B8HfWISfSgw_xVX475CbJGh_QnpOe9MH65H8qGjTWbY,46
@@ -73,9 +73,9 @@ fmtr/tools/tests/test_environment.py,sha256=iHaiMQfECYZPkPKwfuIZV9uHuWe3aE-p_dN_
73
73
  fmtr/tools/tests/test_json.py,sha256=IeSP4ziPvRcmS8kq7k9tHonC9rN5YYq9GSNT2ul6Msk,287
74
74
  fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g,2188
75
75
  fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
76
- fmtr_tools-1.2.5.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
77
- fmtr_tools-1.2.5.dist-info/METADATA,sha256=XH7DX192P5cYVOFAn4DR6Yh1lkAniyNoe6GWJA4p_ug,15943
78
- fmtr_tools-1.2.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
79
- fmtr_tools-1.2.5.dist-info/entry_points.txt,sha256=fSQrDGNctdQXbUxpMWYVfVQ0mhZMDyaEDG3D3a0zOSc,278
80
- fmtr_tools-1.2.5.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
81
- fmtr_tools-1.2.5.dist-info/RECORD,,
76
+ fmtr_tools-1.2.6.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
77
+ fmtr_tools-1.2.6.dist-info/METADATA,sha256=NE-9BBFqSBwTTLeaO5Fz2VpZO1KmolLzAoEmTl_Z5xA,16025
78
+ fmtr_tools-1.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
79
+ fmtr_tools-1.2.6.dist-info/entry_points.txt,sha256=fSQrDGNctdQXbUxpMWYVfVQ0mhZMDyaEDG3D3a0zOSc,278
80
+ fmtr_tools-1.2.6.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
81
+ fmtr_tools-1.2.6.dist-info/RECORD,,