absfuyu 5.10.0__py3-none-any.whl → 5.12.0__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 absfuyu might be problematic. Click here for more details.

Files changed (82) hide show
  1. absfuyu/__init__.py +1 -1
  2. absfuyu/__main__.py +2 -2
  3. absfuyu/cli/__init__.py +2 -2
  4. absfuyu/cli/color.py +2 -2
  5. absfuyu/cli/config_group.py +2 -2
  6. absfuyu/cli/do_group.py +2 -2
  7. absfuyu/cli/game_group.py +2 -2
  8. absfuyu/cli/tool_group.py +2 -2
  9. absfuyu/config/__init__.py +2 -2
  10. absfuyu/core/__init__.py +2 -2
  11. absfuyu/core/baseclass.py +20 -3
  12. absfuyu/core/baseclass2.py +2 -2
  13. absfuyu/core/decorator.py +2 -2
  14. absfuyu/core/docstring.py +2 -2
  15. absfuyu/core/dummy_cli.py +3 -3
  16. absfuyu/core/dummy_func.py +2 -2
  17. absfuyu/dxt/__init__.py +2 -2
  18. absfuyu/dxt/dictext.py +186 -6
  19. absfuyu/dxt/dxt_support.py +2 -2
  20. absfuyu/dxt/intext.py +2 -2
  21. absfuyu/dxt/listext.py +320 -7
  22. absfuyu/dxt/strext.py +2 -2
  23. absfuyu/extra/__init__.py +2 -2
  24. absfuyu/extra/beautiful.py +2 -2
  25. absfuyu/extra/da/__init__.py +2 -2
  26. absfuyu/extra/da/dadf.py +73 -3
  27. absfuyu/extra/da/dadf_base.py +2 -2
  28. absfuyu/extra/da/df_func.py +2 -2
  29. absfuyu/extra/da/mplt.py +2 -2
  30. absfuyu/extra/data_analysis.py +2 -2
  31. absfuyu/extra/pdf.py +2 -2
  32. absfuyu/extra/rclone.py +2 -2
  33. absfuyu/extra/xml.py +2 -2
  34. absfuyu/fun/__init__.py +2 -2
  35. absfuyu/fun/rubik.py +2 -2
  36. absfuyu/fun/tarot.py +2 -2
  37. absfuyu/game/__init__.py +2 -2
  38. absfuyu/game/game_stat.py +2 -2
  39. absfuyu/game/schulte.py +2 -2
  40. absfuyu/game/sudoku.py +2 -2
  41. absfuyu/game/tictactoe.py +2 -2
  42. absfuyu/game/wordle.py +2 -2
  43. absfuyu/general/__init__.py +2 -2
  44. absfuyu/general/content.py +2 -2
  45. absfuyu/general/human.py +2 -2
  46. absfuyu/general/shape.py +2 -2
  47. absfuyu/general/tax.py +344 -0
  48. absfuyu/logger.py +2 -2
  49. absfuyu/pkg_data/__init__.py +2 -2
  50. absfuyu/pkg_data/deprecated.py +2 -2
  51. absfuyu/pkg_data/logo.py +2 -2
  52. absfuyu/sort.py +2 -2
  53. absfuyu/tools/__init__.py +2 -2
  54. absfuyu/tools/checksum.py +2 -2
  55. absfuyu/tools/converter.py +2 -2
  56. absfuyu/tools/generator.py +2 -2
  57. absfuyu/tools/inspector.py +2 -2
  58. absfuyu/tools/keygen.py +2 -2
  59. absfuyu/tools/obfuscator.py +2 -2
  60. absfuyu/tools/passwordlib.py +2 -2
  61. absfuyu/tools/shutdownizer.py +2 -2
  62. absfuyu/tools/sw.py +138 -7
  63. absfuyu/tools/web.py +2 -2
  64. absfuyu/typings.py +5 -2
  65. absfuyu/util/__init__.py +2 -2
  66. absfuyu/util/api.py +2 -2
  67. absfuyu/util/cli.py +118 -0
  68. absfuyu/util/gui.py +2 -2
  69. absfuyu/util/json_method.py +2 -2
  70. absfuyu/util/lunar.py +2 -2
  71. absfuyu/util/path.py +2 -2
  72. absfuyu/util/performance.py +2 -2
  73. absfuyu/util/shorten_number.py +2 -2
  74. absfuyu/util/text_table.py +2 -2
  75. absfuyu/util/zipped.py +2 -2
  76. absfuyu/version.py +2 -2
  77. {absfuyu-5.10.0.dist-info → absfuyu-5.12.0.dist-info}/METADATA +1 -1
  78. absfuyu-5.12.0.dist-info/RECORD +86 -0
  79. absfuyu-5.10.0.dist-info/RECORD +0 -84
  80. {absfuyu-5.10.0.dist-info → absfuyu-5.12.0.dist-info}/WHEEL +0 -0
  81. {absfuyu-5.10.0.dist-info → absfuyu-5.12.0.dist-info}/entry_points.txt +0 -0
  82. {absfuyu-5.10.0.dist-info → absfuyu-5.12.0.dist-info}/licenses/LICENSE +0 -0
absfuyu/__init__.py CHANGED
@@ -22,7 +22,7 @@ Using in cmd:
22
22
  __title__ = "absfuyu"
23
23
  __author__ = "AbsoluteWinter"
24
24
  __license__ = "MIT License"
25
- __version__ = "5.10.0"
25
+ __version__ = "5.12.0"
26
26
  __all__ = [
27
27
  "core",
28
28
  "config",
absfuyu/__main__.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU
3
3
  -------
4
4
  COMMAND LINE INTERFACE
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Library
absfuyu/cli/__init__.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU
3
3
  -------
4
4
  COMMAND LINE INTERFACE
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  __all__ = ["cli"]
absfuyu/cli/color.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Color
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Config
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/cli/do_group.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Do
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/cli/game_group.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Game
5
5
 
6
- Version: 5.10.0
7
- Date updated: 25/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/cli/tool_group.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Tool
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -3,8 +3,8 @@ Absfuyu: Configuration
3
3
  ----------------------
4
4
  Package configuration module
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
absfuyu/core/__init__.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Bases for other features
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/core/baseclass.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Bases for other features
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -57,7 +57,8 @@ class BaseDataclass:
57
57
  Base dataclass.
58
58
 
59
59
  Contains util methods:
60
- - Get fields
60
+ - _get_fields
61
+ - to_dict
61
62
  """
62
63
 
63
64
  @classmethod
@@ -73,6 +74,22 @@ class BaseDataclass:
73
74
  _fields = getattr(cls, "__dataclass_fields__", ())
74
75
  return tuple(_fields)
75
76
 
77
+ # @versionadded("5.11.0")
78
+ def to_dict(self):
79
+ """
80
+ Convert dataclass into dict
81
+
82
+ Returns
83
+ -------
84
+ dict
85
+ Dataclass converted into dict
86
+ """
87
+ fields = self._get_fields()
88
+ output = {}
89
+ for field in fields:
90
+ output.__setitem__(field, self.__getattribute__(field))
91
+ return output
92
+
76
93
 
77
94
  # Support
78
95
  # ---------------------------------------------------------------------------
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Bases for other features (with library)
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/core/decorator.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Decorator
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/core/docstring.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Sphinx docstring decorator
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/core/dummy_cli.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Dummy cli
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -57,7 +57,7 @@ def get_parser(
57
57
 
58
58
 
59
59
  def cli() -> None:
60
- desc = "This is a dummy cli, please install <click> and <colorama> package to use this feature"
60
+ desc = "This is a dummy cli, install <click> and <colorama> package to use this feature"
61
61
  arg_parser = get_parser(
62
62
  name=__title__,
63
63
  description=desc,
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Dummy functions when other libraries are unvailable
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/dxt/__init__.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  Extension for data type such as ``list``, ``str``, ``dict``, ...
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
 
9
9
  Features:
10
10
  ---------
absfuyu/dxt/dictext.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  dict extension
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -16,7 +16,7 @@ __all__ = ["DictExt", "DictAnalyzeResult"]
16
16
  # ---------------------------------------------------------------------------
17
17
  import operator
18
18
  from collections.abc import Callable
19
- from typing import Any, NamedTuple, Self, TypeVar
19
+ from typing import Any, Literal, NamedTuple, Self, TypeVar, overload
20
20
 
21
21
  from absfuyu.core import GetClassMembersMixin, versionadded, versionchanged
22
22
 
@@ -28,6 +28,8 @@ from absfuyu.core import GetClassMembersMixin, versionadded, versionchanged
28
28
  # ---------------------------------------------------------------------------
29
29
  KT = TypeVar("KT")
30
30
  VT = TypeVar("VT")
31
+ VT2 = TypeVar("VT2")
32
+ R = TypeVar("R") # Return type - Can be anything
31
33
 
32
34
 
33
35
  # Class
@@ -43,9 +45,9 @@ class DictAnalyzeResult(NamedTuple):
43
45
  min_list: list
44
46
 
45
47
 
46
- class DictExt(GetClassMembersMixin, dict[KT, VT]):
48
+ class DictExtLegacy(GetClassMembersMixin, dict[KT, VT]):
47
49
  """
48
- ``dict`` extension
50
+ ``dict`` extension (with no generic type-hints)
49
51
 
50
52
  >>> # For a list of new methods
51
53
  >>> DictExt.show_all_methods()
@@ -107,7 +109,7 @@ class DictExt(GetClassMembersMixin, dict[KT, VT]):
107
109
  {9: 'abc'}
108
110
  """
109
111
  # return self.__class__(zip(self.values(), self.keys()))
110
- return self.__class__({v: k for k, v in self.items()})
112
+ return self.__class__({v: k for k, v in self.items()}) # type: ignore
111
113
 
112
114
  def apply(self, func: Callable[[Any], Any], apply_to_value: bool = True) -> Self:
113
115
  """
@@ -205,3 +207,181 @@ class DictExt(GetClassMembersMixin, dict[KT, VT]):
205
207
  merged_output[k] = [value_self, value_other]
206
208
 
207
209
  return self.__class__(merged_output)
210
+
211
+
212
+ # Type-hints are hard coded, no work around Self[KT, VT] yet
213
+ class DictExt(GetClassMembersMixin, dict[KT, VT]):
214
+ """
215
+ ``dict`` extension
216
+
217
+ >>> # For a list of new methods
218
+ >>> DictExt.show_all_methods()
219
+ """
220
+
221
+ # Analyze
222
+ @versionchanged("3.3.0", reason="Updated return type")
223
+ def analyze(self) -> DictAnalyzeResult:
224
+ """
225
+ Analyze all the key values (``int``, ``float``)
226
+ in ``dict`` then return highest/lowest index
227
+
228
+ Returns
229
+ -------
230
+ dict
231
+ Analyzed data
232
+
233
+
234
+ Example:
235
+ --------
236
+ >>> test = DictExt({"abc": 9, "def": 9, "ghi": 8, "jkl": 1, "mno": 1})
237
+ >>> test.analyze()
238
+ DictAnalyzeResult(max_value=9, min_value=1, max_list=[('abc', 9), ('def', 9)], min_list=[('jkl', 1), ('mno', 1)])
239
+ """
240
+ try:
241
+ dct: dict = self.copy()
242
+
243
+ max_val: int | float = max(list(dct.values()))
244
+ min_val: int | float = min(list(dct.values()))
245
+ max_list = []
246
+ min_list = []
247
+
248
+ for k, v in dct.items():
249
+ if v == max_val:
250
+ max_list.append((k, v))
251
+ if v == min_val:
252
+ min_list.append((k, v))
253
+
254
+ return DictAnalyzeResult(max_val, min_val, max_list, min_list)
255
+
256
+ except TypeError:
257
+ err_msg = "Value must be int or float"
258
+ # logger.error(err_msg)
259
+ raise ValueError(err_msg) # noqa: B904
260
+
261
+ # Swap
262
+ def swap_items(self) -> "DictExt[VT, KT]":
263
+ """
264
+ Swap ``dict.keys()`` with ``dict.values()``
265
+
266
+ Returns
267
+ -------
268
+ DictExt
269
+ Swapped dict
270
+
271
+
272
+ Example:
273
+ --------
274
+ >>> test = DictExt({"abc": 9})
275
+ >>> test.swap_items()
276
+ {9: 'abc'}
277
+ """
278
+ # return self.__class__(zip(self.values(), self.keys()))
279
+ out: dict[VT, KT] = {v: k for k, v in self.items()}
280
+ # return self.__class__({v: k for k, v in self.items()}) # type: ignore
281
+ return self.__class__(out) # type: ignore
282
+
283
+ # Apply
284
+ @overload
285
+ def apply(self, func: Callable[[VT], R]) -> "DictExt[KT, R]": ...
286
+
287
+ @overload
288
+ def apply(self, func: Callable[[KT], R], apply_to_value: Literal[False] = ...) -> "DictExt[R, VT]": ...
289
+
290
+ def apply(self, func: Callable[[KT | VT], R], apply_to_value: bool = True): # type: ignore
291
+ """
292
+ Apply function to ``DictExt.keys()`` or ``DictExt.values()``
293
+
294
+ Parameters
295
+ ----------
296
+ func : Callable
297
+ Callable function
298
+
299
+ apply_to_value : bool
300
+ | ``True``: Apply ``func`` to ``DictExt.values()``
301
+ | ``False``: Apply ``func`` to ``DictExt.keys()``
302
+
303
+ Returns
304
+ -------
305
+ DictExt
306
+ DictExt
307
+
308
+
309
+ Example:
310
+ --------
311
+ >>> test = DictExt({"abc": 9})
312
+ >>> test.apply(str)
313
+ {'abc': '9'}
314
+ """
315
+ if apply_to_value:
316
+ new_dict_v: dict[KT, R] = {k: func(v) for k, v in self.items()}
317
+ return self.__class__(new_dict_v) # type: ignore
318
+ else:
319
+ new_dict_k: dict[R, VT] = {func(k): v for k, v in self.items()}
320
+ return self.__class__(new_dict_k) # type: ignore
321
+
322
+ # Aggregate
323
+ @versionchanged("5.0.0", reason="Updated to handle more types and operator")
324
+ @versionadded("3.4.0")
325
+ def aggregate(
326
+ self,
327
+ other_dict: dict[KT, VT | VT2],
328
+ default_value: Any = 0,
329
+ operator_func: Callable[[Any, Any], R] = operator.add, # operator add
330
+ ):
331
+ """
332
+ Aggregates the values of the current dictionary with another dictionary.
333
+
334
+ For each unique key, this method applies the specified operator to the values
335
+ from both dictionaries. If a key exists in only one dictionary, its value is used.
336
+ If an error occurs during aggregation (e.g., incompatible types), the values
337
+ from both dictionaries are returned as a list.
338
+
339
+ Parameters
340
+ ----------
341
+ other_dict : dict
342
+ The dictionary to aggregate with.
343
+
344
+ default_value : Any, optional
345
+ The value to use for missing keys, by default ``0``
346
+
347
+
348
+ operator_func : Callable[[Any, Any], Any], optional
349
+ A function that takes two arguments and returns a single value,
350
+ by default ``operator.add``
351
+
352
+ Returns
353
+ -------
354
+ Self
355
+ A new instance of the aggregated dictionary.
356
+
357
+
358
+ Example:
359
+ --------
360
+ >>> test = DictExt({"test": 5, "test2": 9})
361
+ >>> agg = {"test1": 10, "test2": 1}
362
+ >>> print(test.aggregate(agg))
363
+ {'test1': 10, 'test': 5, 'test2': 10}
364
+
365
+ >>> test = DictExt({"test": 5, "test2": 9})
366
+ >>> agg = {"test1": 10, "test2": "1"}
367
+ >>> print(test.aggregate(agg))
368
+ {'test1': 10, 'test': 5, 'test2': [9, '1']}
369
+ """
370
+ merged_output: dict[KT, VT | R | list[VT | VT2]] = {}
371
+
372
+ # Create a set of all unique keys from both dictionaries
373
+ all_keys = set(self) | set(other_dict)
374
+
375
+ for k in all_keys:
376
+ # Retrieve values with default fallback
377
+ value_self = self.get(k, default_value)
378
+ value_other = other_dict.get(k, default_value)
379
+
380
+ try:
381
+ # Attempt to apply the operator for existing keys
382
+ merged_output[k] = operator_func(value_self, value_other)
383
+ except TypeError:
384
+ # If a TypeError occurs (e.g., if values are not compatible), store values as a list
385
+ merged_output[k] = [value_self, value_other] # type: ignore
386
+
387
+ return self.__class__(merged_output) # type: ignore
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  Support classes
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/dxt/intext.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  int extension
5
5
 
6
- Version: 5.10.0
7
- Date updated: 23/09/2025 (dd/mm/yyyy)
6
+ Version: 5.12.0
7
+ Date updated: 17/10/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package