fmtr.tools 1.3.77__py3-none-any.whl → 1.3.79__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,8 +1,10 @@
1
- from functools import cached_property
2
- from typing import Optional
3
-
4
1
  import flet as ft
2
+ from dataclasses import dataclass
5
3
  from flet.core.gesture_detector import TapEvent
4
+ from flet.core.page import Page
5
+ from flet.core.types import ColorValue, IconValue
6
+ from functools import cached_property
7
+ from typing import Optional
6
8
 
7
9
  from fmtr.tools.logging_tools import logger
8
10
 
@@ -124,7 +126,7 @@ class Row(ft.DataRow):
124
126
 
125
127
  """
126
128
 
127
- TypeCell = Cell
129
+ TypesCells = {None: Cell}
128
130
 
129
131
  def __init__(self, series):
130
132
  self.series = series
@@ -139,7 +141,9 @@ class Row(ft.DataRow):
139
141
  """
140
142
  data = {}
141
143
  for col in self.series.index:
142
- data.setdefault(col, []).append(self.TypeCell(self.series, col))
144
+ default = self.TypesCells[None]
145
+ TypeCell = self.TypesCells.get(col, default)
146
+ data.setdefault(col, []).append(TypeCell(self.series, col))
143
147
  return data
144
148
 
145
149
  @cached_property
@@ -217,8 +221,8 @@ class Table(ft.DataTable):
217
221
 
218
222
  """
219
223
 
220
- TypeRow = Row
221
- TypeColumn = Column
224
+ TypesRows = {None: Row}
225
+ TypesColumns = {None: Column}
222
226
 
223
227
  def __init__(self, df): # todo move to submodule with tabular deps
224
228
  """
@@ -227,8 +231,34 @@ class Table(ft.DataTable):
227
231
 
228
232
  """
229
233
  self.df = df
230
- columns = [self.TypeColumn(col) for col in df.columns]
231
- super().__init__(columns=columns, rows=self.rows_controls)
234
+ super().__init__(columns=self.columns_controls, rows=self.rows_controls)
235
+
236
+ @cached_property
237
+ def columns_data(self) -> dict[str, list[Column]]:
238
+ """
239
+
240
+ Columns controls lookup
241
+
242
+ """
243
+ data = {}
244
+ for col in self.df.columns:
245
+ default = self.TypesColumns[None]
246
+ TypeColumn = self.TypesColumns.get(col, default)
247
+ data.setdefault(col, []).append(TypeColumn(col))
248
+ return data
249
+
250
+ @cached_property
251
+ def columns_controls(self) -> list[Column]:
252
+ """
253
+
254
+ Flat list of controls
255
+
256
+ """
257
+ controls = []
258
+ for columns in self.columns_data.values():
259
+ for column in columns:
260
+ controls.append(column)
261
+ return controls
232
262
 
233
263
  @cached_property
234
264
  def rows_data(self) -> dict[str, list[Row]]:
@@ -239,7 +269,9 @@ class Table(ft.DataTable):
239
269
  """
240
270
  data = {}
241
271
  for index, row in self.df.iterrows():
242
- data.setdefault(index, []).append(self.TypeRow(row))
272
+ default = self.TypesRows[None]
273
+ TypeRow = self.TypesRows.get(index, default)
274
+ data.setdefault(index, []).append(TypeRow(row))
243
275
  return data
244
276
 
245
277
  @cached_property
@@ -263,3 +295,61 @@ class Table(ft.DataTable):
263
295
  """
264
296
 
265
297
  return self.rows_data[item]
298
+
299
+
300
+ @dataclass
301
+ class NotificationDatum:
302
+ """
303
+
304
+ Color and icon for notification bar
305
+
306
+ """
307
+ color: ColorValue
308
+ icon: IconValue
309
+
310
+
311
+ class NotificationBar(ft.SnackBar):
312
+ """
313
+
314
+ Combined logging and notification bar: infers the appropriate UI representation from the log level
315
+
316
+ """
317
+ DATA = {
318
+ logger.info: NotificationDatum(color=ft.Colors.BLUE, icon=ft.Icons.INFO),
319
+ logger.warning: NotificationDatum(color=ft.Colors.AMBER, icon=ft.Icons.WARNING),
320
+ logger.error: NotificationDatum(color=ft.Colors.RED, icon=ft.Icons.ERROR),
321
+ logger.debug: NotificationDatum(color=ft.Colors.GREY, icon=ft.Icons.BUG_REPORT),
322
+ logger.exception: NotificationDatum(color=ft.Colors.RED_ACCENT, icon=ft.Icons.REPORT),
323
+ }
324
+
325
+ def __init__(self, msg: str, method=logger.info):
326
+ """
327
+
328
+ Log the message immediately, otherwise configure notification bar icon/color.
329
+
330
+ """
331
+ self.msg = msg
332
+ self.method = method
333
+ self.method(msg)
334
+
335
+ icon = ft.Icon(self.data.icon, color=self.data.color)
336
+ text = ft.Text(self.msg)
337
+ content = ft.Row(controls=[icon, text])
338
+ super().__init__(content=content)
339
+
340
+ @cached_property
341
+ def data(self) -> NotificationDatum:
342
+ """
343
+
344
+ Fetching data using logging method.
345
+
346
+ """
347
+ return self.DATA[self.method]
348
+
349
+ def show(self, page: Page):
350
+ """
351
+
352
+ Show the notification on the relevant page.
353
+
354
+ """
355
+ page.open(self)
fmtr/tools/version CHANGED
@@ -1 +1 @@
1
- 1.3.77
1
+ 1.3.79
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fmtr.tools
3
- Version: 1.3.77
3
+ Version: 1.3.79
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/fmtr.tools
6
6
  Author: Frontmatter
@@ -166,67 +166,67 @@ Provides-Extra: db
166
166
  Provides-Extra: db-document
167
167
  Requires-Dist: beanie[odm]; extra == "db-document"
168
168
  Provides-Extra: all
169
- Requires-Dist: tabulate; extra == "all"
170
- Requires-Dist: Unidecode; extra == "all"
169
+ Requires-Dist: fastapi; extra == "all"
170
+ Requires-Dist: tokenizers; extra == "all"
171
+ Requires-Dist: flet-video; extra == "all"
172
+ Requires-Dist: json_repair; extra == "all"
173
+ Requires-Dist: deepmerge; extra == "all"
171
174
  Requires-Dist: pycountry; extra == "all"
172
- Requires-Dist: flet-webview; extra == "all"
173
- Requires-Dist: appdirs; extra == "all"
174
- Requires-Dist: html2text; extra == "all"
175
- Requires-Dist: logfire; extra == "all"
176
- Requires-Dist: bokeh; extra == "all"
177
- Requires-Dist: google-auth-oauthlib; extra == "all"
178
- Requires-Dist: pytest-cov; extra == "all"
179
- Requires-Dist: pymupdf; extra == "all"
180
- Requires-Dist: httpx; extra == "all"
181
- Requires-Dist: logfire[httpx]; extra == "all"
182
- Requires-Dist: setuptools; extra == "all"
183
- Requires-Dist: regex; extra == "all"
184
175
  Requires-Dist: python-on-whales; extra == "all"
185
- Requires-Dist: semver; extra == "all"
176
+ Requires-Dist: torchvision; extra == "all"
186
177
  Requires-Dist: pandas; extra == "all"
187
- Requires-Dist: playwright; extra == "all"
178
+ Requires-Dist: google-auth-httplib2; extra == "all"
179
+ Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
180
+ Requires-Dist: pydantic-settings; extra == "all"
181
+ Requires-Dist: contexttimer; extra == "all"
182
+ Requires-Dist: beanie[odm]; extra == "all"
183
+ Requires-Dist: google-auth-oauthlib; extra == "all"
184
+ Requires-Dist: uvicorn[standard]; extra == "all"
185
+ Requires-Dist: peft; extra == "all"
186
+ Requires-Dist: tinynetrc; extra == "all"
188
187
  Requires-Dist: faker; extra == "all"
189
- Requires-Dist: transformers[sentencepiece]; extra == "all"
190
- Requires-Dist: httpx_retries; extra == "all"
191
- Requires-Dist: odfpy; extra == "all"
188
+ Requires-Dist: pydantic; extra == "all"
189
+ Requires-Dist: pytest-cov; extra == "all"
190
+ Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
191
+ Requires-Dist: playwright; extra == "all"
192
192
  Requires-Dist: logfire[fastapi]; extra == "all"
193
- Requires-Dist: pydantic-settings; extra == "all"
194
- Requires-Dist: pymupdf4llm; extra == "all"
195
- Requires-Dist: ollama; extra == "all"
196
- Requires-Dist: pyyaml; extra == "all"
197
- Requires-Dist: pydevd-pycharm~=251.25410.159; extra == "all"
198
- Requires-Dist: dask[bag]; extra == "all"
199
- Requires-Dist: sre_yield; extra == "all"
200
- Requires-Dist: deepdiff; extra == "all"
193
+ Requires-Dist: appdirs; extra == "all"
194
+ Requires-Dist: semver; extra == "all"
201
195
  Requires-Dist: flet[all]; extra == "all"
202
- Requires-Dist: openai; extra == "all"
203
- Requires-Dist: dnspython[doh]; extra == "all"
204
- Requires-Dist: json_repair; extra == "all"
196
+ Requires-Dist: bokeh; extra == "all"
197
+ Requires-Dist: setuptools; extra == "all"
198
+ Requires-Dist: Unidecode; extra == "all"
199
+ Requires-Dist: logfire; extra == "all"
205
200
  Requires-Dist: pydantic-extra-types; extra == "all"
206
- Requires-Dist: pydantic; extra == "all"
207
- Requires-Dist: flet-video; extra == "all"
208
- Requires-Dist: sentence_transformers; extra == "all"
209
- Requires-Dist: google-auth; extra == "all"
210
- Requires-Dist: filetype; extra == "all"
211
- Requires-Dist: torchaudio; extra == "all"
212
- Requires-Dist: deepmerge; extra == "all"
213
- Requires-Dist: google-auth-httplib2; extra == "all"
214
- Requires-Dist: diskcache; extra == "all"
215
- Requires-Dist: peft; extra == "all"
216
- Requires-Dist: fastapi; extra == "all"
201
+ Requires-Dist: flet-webview; extra == "all"
202
+ Requires-Dist: html2text; extra == "all"
203
+ Requires-Dist: dnspython[doh]; extra == "all"
217
204
  Requires-Dist: yamlscript; extra == "all"
218
- Requires-Dist: contexttimer; extra == "all"
219
- Requires-Dist: uvicorn[standard]; extra == "all"
220
- Requires-Dist: pydantic-ai[logfire,openai]; extra == "all"
205
+ Requires-Dist: tabulate; extra == "all"
206
+ Requires-Dist: logfire[httpx]; extra == "all"
207
+ Requires-Dist: pyyaml; extra == "all"
208
+ Requires-Dist: pymupdf; extra == "all"
209
+ Requires-Dist: pymupdf4llm; extra == "all"
221
210
  Requires-Dist: google-api-python-client; extra == "all"
222
- Requires-Dist: cachetools; extra == "all"
223
- Requires-Dist: huggingface_hub; extra == "all"
224
- Requires-Dist: tinynetrc; extra == "all"
211
+ Requires-Dist: torchaudio; extra == "all"
225
212
  Requires-Dist: openpyxl; extra == "all"
226
- Requires-Dist: beanie[odm]; extra == "all"
213
+ Requires-Dist: cachetools; extra == "all"
214
+ Requires-Dist: dask[bag]; extra == "all"
227
215
  Requires-Dist: distributed; extra == "all"
228
- Requires-Dist: torchvision; extra == "all"
229
- Requires-Dist: tokenizers; extra == "all"
216
+ Requires-Dist: httpx_retries; extra == "all"
217
+ Requires-Dist: transformers[sentencepiece]; extra == "all"
218
+ Requires-Dist: openai; extra == "all"
219
+ Requires-Dist: google-auth; extra == "all"
220
+ Requires-Dist: ollama; extra == "all"
221
+ Requires-Dist: sentence_transformers; extra == "all"
222
+ Requires-Dist: huggingface_hub; extra == "all"
223
+ Requires-Dist: odfpy; extra == "all"
224
+ Requires-Dist: sre_yield; extra == "all"
225
+ Requires-Dist: diskcache; extra == "all"
226
+ Requires-Dist: httpx; extra == "all"
227
+ Requires-Dist: deepdiff; extra == "all"
228
+ Requires-Dist: filetype; extra == "all"
229
+ Requires-Dist: regex; extra == "all"
230
230
  Dynamic: author
231
231
  Dynamic: author-email
232
232
  Dynamic: description
@@ -45,7 +45,7 @@ fmtr/tools/tabular_tools.py,sha256=mw6vOij1Ch-pVAyHMPtm5zj__ULZN_TKeBYOfj33wFM,1
45
45
  fmtr/tools/tokenization_tools.py,sha256=me-IBzSLyNYejLybwjO9CNB6Mj2NYfKPaOVThXyaGNg,4268
46
46
  fmtr/tools/tools.py,sha256=sLMXk8juOL8_n_D776cJ-kzjyMHqFI_fctDEjy6PIKs,1115
47
47
  fmtr/tools/unicode_tools.py,sha256=yS_9wpu8ogNoiIL7s1G_8bETFFO_YQlo4LNPv1NLDeY,52
48
- fmtr/tools/version,sha256=na4GGRTt6420NX2ci0UNn8rQr1h_nmfw9KWI9iZSYNE,6
48
+ fmtr/tools/version,sha256=nUbdl36ANzDqxVZspE2k186qHKJ-1fUrAoWrOkJxxdo,6
49
49
  fmtr/tools/webhook_tools.py,sha256=q3pVJ1NCem2SrMuFcLxiWd7DibFs7Q-uGtojfXd3Qcg,380
50
50
  fmtr/tools/yaml_tools.py,sha256=Bhhyd6GQVKO72Lp8ky7bAUjIB_65Hdh0Q45SKIEe6S8,1901
51
51
  fmtr/tools/ai_tools/__init__.py,sha256=O8VRlPnnQCncg2ZZ2l_VdWLJf4jkKH6dkZFVbv6o7IM,388
@@ -67,7 +67,7 @@ fmtr/tools/entrypoints/remote_debug_test.py,sha256=wmKg9o2pQq7eqeHmaO8oviujNgtns
67
67
  fmtr/tools/entrypoints/shell_debug.py,sha256=0No3tAg9Ri4_vvSlQCUtAY-11HR0nE45i0VVtiAViwY,106
68
68
  fmtr/tools/interface_tools/__init__.py,sha256=_bgZRTqmygtYM75o6_zyQRhT_XZnDERZEHmsYVrzyxw,393
69
69
  fmtr/tools/interface_tools/context.py,sha256=VpoR_ZCndDbwS0AzIPKi1hB2QckwJU5dJqAJavF3mqk,151
70
- fmtr/tools/interface_tools/controls.py,sha256=fsSK74VPdJ9QEo2nAE5Mn0pJOzHbWyWojnQ8Rg7s_Oc,5199
70
+ fmtr/tools/interface_tools/controls.py,sha256=sfP9-Vuws7v05WQQhsALwMyvymDbtK7VAHxgKyWQfr0,7651
71
71
  fmtr/tools/interface_tools/interface_tools.py,sha256=jSRwpdHqOTmNLndE-wFqTQdkT4z2BBdclSxmvs11FnU,4400
72
72
  fmtr/tools/path_tools/__init__.py,sha256=XrJXt7Zzo90tYUVksMlDfKkWt775zJ9OSi2NbhnqMDI,459
73
73
  fmtr/tools/path_tools/app_path_tools.py,sha256=JrJvtTDd_gkCKcZtBCDTMktsM77PZwGV_hzQX0g5GU8,1722
@@ -85,9 +85,9 @@ fmtr/tools/tests/test_path.py,sha256=AkZQa6_8BQ-VaCyL_J-iKmdf2ZaM-xFYR37Kun3k4_g
85
85
  fmtr/tools/tests/test_yaml.py,sha256=jc0TwwKu9eC0LvFGNMERdgBue591xwLxYXFbtsRwXVM,287
86
86
  fmtr/tools/version_tools/__init__.py,sha256=cjE6nO6AoVOUp3RwgTbqL9wiw8J1l2pHJOz6Gn6bxjA,326
87
87
  fmtr/tools/version_tools/version_tools.py,sha256=Hcc6yferZS1hHbugRTdiHhSNmXEEG0hjCiTTXKna-YY,1127
88
- fmtr_tools-1.3.77.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
- fmtr_tools-1.3.77.dist-info/METADATA,sha256=hyS9qbFA6ohQeSv_fb31rRWFJvtlMszJx2u3LPH9YwI,17916
90
- fmtr_tools-1.3.77.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
- fmtr_tools-1.3.77.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
- fmtr_tools-1.3.77.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
- fmtr_tools-1.3.77.dist-info/RECORD,,
88
+ fmtr_tools-1.3.79.dist-info/licenses/LICENSE,sha256=FW9aa6vVN5IjRQWLT43hs4_koYSmpcbIovlKeAJ0_cI,10757
89
+ fmtr_tools-1.3.79.dist-info/METADATA,sha256=jk9fr_Jqd01XOBdH48JxQohcMQJsRlhyXgGlyM36EPw,17916
90
+ fmtr_tools-1.3.79.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
91
+ fmtr_tools-1.3.79.dist-info/entry_points.txt,sha256=h-r__Xh5njtFqreMLg6cGuTFS4Qh-QqJPU1HB-_BS-Q,357
92
+ fmtr_tools-1.3.79.dist-info/top_level.txt,sha256=LXem9xCgNOD72tE2gRKESdiQTL902mfFkwWb6-dlwEE,5
93
+ fmtr_tools-1.3.79.dist-info/RECORD,,