absfuyu 5.0.0__py3-none-any.whl → 6.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.

Potentially problematic release.


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

Files changed (103) hide show
  1. absfuyu/__init__.py +5 -3
  2. absfuyu/__main__.py +3 -3
  3. absfuyu/cli/__init__.py +13 -2
  4. absfuyu/cli/audio_group.py +98 -0
  5. absfuyu/cli/color.py +30 -14
  6. absfuyu/cli/config_group.py +9 -2
  7. absfuyu/cli/do_group.py +23 -6
  8. absfuyu/cli/game_group.py +27 -2
  9. absfuyu/cli/tool_group.py +81 -11
  10. absfuyu/config/__init__.py +3 -3
  11. absfuyu/core/__init__.py +12 -8
  12. absfuyu/core/baseclass.py +929 -96
  13. absfuyu/core/baseclass2.py +44 -3
  14. absfuyu/core/decorator.py +70 -4
  15. absfuyu/core/docstring.py +64 -41
  16. absfuyu/core/dummy_cli.py +3 -3
  17. absfuyu/core/dummy_func.py +19 -6
  18. absfuyu/dxt/__init__.py +2 -2
  19. absfuyu/dxt/base_type.py +93 -0
  20. absfuyu/dxt/dictext.py +204 -16
  21. absfuyu/dxt/dxt_support.py +2 -2
  22. absfuyu/dxt/intext.py +151 -34
  23. absfuyu/dxt/listext.py +969 -127
  24. absfuyu/dxt/strext.py +77 -17
  25. absfuyu/extra/__init__.py +2 -2
  26. absfuyu/extra/audio/__init__.py +8 -0
  27. absfuyu/extra/audio/_util.py +57 -0
  28. absfuyu/extra/audio/convert.py +192 -0
  29. absfuyu/extra/audio/lossless.py +281 -0
  30. absfuyu/extra/beautiful.py +3 -2
  31. absfuyu/extra/da/__init__.py +72 -0
  32. absfuyu/extra/da/dadf.py +1600 -0
  33. absfuyu/extra/da/dadf_base.py +186 -0
  34. absfuyu/extra/da/df_func.py +181 -0
  35. absfuyu/extra/da/mplt.py +219 -0
  36. absfuyu/extra/ggapi/__init__.py +8 -0
  37. absfuyu/extra/ggapi/gdrive.py +223 -0
  38. absfuyu/extra/ggapi/glicense.py +148 -0
  39. absfuyu/extra/ggapi/glicense_df.py +186 -0
  40. absfuyu/extra/ggapi/gsheet.py +88 -0
  41. absfuyu/extra/img/__init__.py +30 -0
  42. absfuyu/extra/img/converter.py +402 -0
  43. absfuyu/extra/img/dup_check.py +291 -0
  44. absfuyu/extra/pdf.py +87 -0
  45. absfuyu/extra/rclone.py +253 -0
  46. absfuyu/extra/xml.py +90 -0
  47. absfuyu/fun/__init__.py +7 -20
  48. absfuyu/fun/rubik.py +442 -0
  49. absfuyu/fun/tarot.py +2 -2
  50. absfuyu/game/__init__.py +2 -2
  51. absfuyu/game/game_stat.py +2 -2
  52. absfuyu/game/schulte.py +78 -0
  53. absfuyu/game/sudoku.py +2 -2
  54. absfuyu/game/tictactoe.py +2 -3
  55. absfuyu/game/wordle.py +6 -4
  56. absfuyu/general/__init__.py +4 -4
  57. absfuyu/general/content.py +4 -4
  58. absfuyu/general/human.py +2 -2
  59. absfuyu/general/resrel.py +213 -0
  60. absfuyu/general/shape.py +3 -8
  61. absfuyu/general/tax.py +344 -0
  62. absfuyu/logger.py +806 -59
  63. absfuyu/numbers/__init__.py +13 -0
  64. absfuyu/numbers/number_to_word.py +321 -0
  65. absfuyu/numbers/shorten_number.py +303 -0
  66. absfuyu/numbers/time_duration.py +217 -0
  67. absfuyu/pkg_data/__init__.py +2 -2
  68. absfuyu/pkg_data/deprecated.py +2 -2
  69. absfuyu/pkg_data/logo.py +1462 -0
  70. absfuyu/sort.py +4 -4
  71. absfuyu/tools/__init__.py +28 -2
  72. absfuyu/tools/checksum.py +144 -9
  73. absfuyu/tools/converter.py +120 -34
  74. absfuyu/tools/generator.py +461 -0
  75. absfuyu/tools/inspector.py +752 -0
  76. absfuyu/tools/keygen.py +2 -2
  77. absfuyu/tools/obfuscator.py +47 -9
  78. absfuyu/tools/passwordlib.py +89 -25
  79. absfuyu/tools/shutdownizer.py +3 -8
  80. absfuyu/tools/sw.py +718 -0
  81. absfuyu/tools/web.py +10 -13
  82. absfuyu/typings.py +138 -0
  83. absfuyu/util/__init__.py +114 -6
  84. absfuyu/util/api.py +41 -18
  85. absfuyu/util/cli.py +119 -0
  86. absfuyu/util/gui.py +91 -0
  87. absfuyu/util/json_method.py +43 -14
  88. absfuyu/util/lunar.py +2 -2
  89. absfuyu/util/package.py +124 -0
  90. absfuyu/util/path.py +702 -82
  91. absfuyu/util/performance.py +122 -7
  92. absfuyu/util/shorten_number.py +244 -21
  93. absfuyu/util/text_table.py +481 -0
  94. absfuyu/util/zipped.py +8 -7
  95. absfuyu/version.py +79 -59
  96. {absfuyu-5.0.0.dist-info → absfuyu-6.1.2.dist-info}/METADATA +52 -11
  97. absfuyu-6.1.2.dist-info/RECORD +105 -0
  98. {absfuyu-5.0.0.dist-info → absfuyu-6.1.2.dist-info}/WHEEL +1 -1
  99. absfuyu/extra/data_analysis.py +0 -1078
  100. absfuyu/general/generator.py +0 -303
  101. absfuyu-5.0.0.dist-info/RECORD +0 -68
  102. {absfuyu-5.0.0.dist-info → absfuyu-6.1.2.dist-info}/entry_points.txt +0 -0
  103. {absfuyu-5.0.0.dist-info → absfuyu-6.1.2.dist-info}/licenses/LICENSE +0 -0
@@ -3,8 +3,8 @@ Absfuyu: Json Method
3
3
  --------------------
4
4
  ``.json`` file handling
5
5
 
6
- Version: 5.0.0
7
- Date updated: 25/02/2025 (dd/mm/yyyy)
6
+ Version: 6.1.1
7
+ Date updated: 30/12/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
@@ -16,7 +16,6 @@ __all__ = ["JsonFile"]
16
16
  # ---------------------------------------------------------------------------
17
17
  import json
18
18
  from pathlib import Path
19
- from typing import Any
20
19
 
21
20
  from absfuyu.core import BaseClass
22
21
 
@@ -26,6 +25,20 @@ from absfuyu.core import BaseClass
26
25
  class JsonFile(BaseClass):
27
26
  """
28
27
  ``.json`` file handling
28
+
29
+ Parameters
30
+ ----------
31
+ json_file_location : str | Path
32
+ .json file location
33
+
34
+ encoding : str | None, optional
35
+ Data encoding, by default ``"utf-8"``
36
+
37
+ indent : int | str | None, optional
38
+ Indentation when export to json file, by default ``4``
39
+
40
+ sort_keys : bool, optional
41
+ Sort the keys before export to json file, by default ``True``
29
42
  """
30
43
 
31
44
  def __init__(
@@ -37,26 +50,40 @@ class JsonFile(BaseClass):
37
50
  sort_keys: bool = True,
38
51
  ) -> None:
39
52
  """
40
- json_file_location: json file location
41
- encoding: data encoding (Default: utf-8)
42
- indent: indentation when export to json file
43
- sort_keys: sort the keys before export to json file
53
+ ``.json`` file handling
54
+
55
+ Parameters
56
+ ----------
57
+ json_file_location : str | Path
58
+ .json file location
59
+
60
+ encoding : str | None, optional
61
+ Data encoding, by default ``"utf-8"``
62
+
63
+ indent : int | str | None, optional
64
+ Indentation when export to json file, by default ``4``
65
+
66
+ sort_keys : bool, optional
67
+ Sort the keys before export to json file, by default ``True``
44
68
  """
69
+
45
70
  self.json_file_location = Path(json_file_location)
46
71
  self.encoding = encoding
47
72
  self.indent = indent
48
73
  self.sort_keys = sort_keys
49
- self.data: dict[Any, Any] = {}
74
+ self.data: dict = {}
50
75
 
51
76
  def __str__(self) -> str:
52
77
  return f"{self.__class__.__name__}({self.json_file_location.name})"
53
78
 
54
- def load_json(self) -> dict[Any, Any]:
79
+ def load_json(self) -> dict:
55
80
  """
56
81
  Load ``.json`` file
57
82
 
58
- :returns: ``.json`` data
59
- :rtype: dict
83
+ Returns
84
+ -------
85
+ dict
86
+ ``.json`` data
60
87
  """
61
88
  with open(self.json_file_location, "r", encoding=self.encoding) as file:
62
89
  self.data = json.load(file)
@@ -68,11 +95,13 @@ class JsonFile(BaseClass):
68
95
  with open(self.json_file_location, "w", encoding=self.encoding) as file:
69
96
  file.writelines(json_data)
70
97
 
71
- def update_data(self, data: dict[Any, Any]) -> None:
98
+ def update_data(self, data: dict) -> None:
72
99
  """
73
100
  Update ``.json`` data without save
74
101
 
75
- :param data: ``.json`` data
76
- :type data: dict
102
+ Parameters
103
+ ----------
104
+ data : dict
105
+ ``.json`` data
77
106
  """
78
107
  self.data = data
absfuyu/util/lunar.py CHANGED
@@ -4,8 +4,8 @@ Absfuyu: Lunar calendar
4
4
  -----------------------
5
5
  Convert to lunar calendar
6
6
 
7
- Version: 1.0.3
8
- Date updated: 15/11/2024 (dd/mm/yyyy)
7
+ Version: 6.1.1
8
+ Date updated: 30/12/2025 (dd/mm/yyyy)
9
9
 
10
10
  Source:
11
11
  -------
@@ -0,0 +1,124 @@
1
+ """
2
+ Absfuyu: Package
3
+ ----------------
4
+ Package related
5
+
6
+ Version: 6.1.1
7
+ Date updated: 30/12/2025 (dd/mm/yyyy)
8
+ """
9
+
10
+ # Module level
11
+ # ---------------------------------------------------------------------------
12
+ __all__ = ["PackageManager"]
13
+
14
+
15
+ # Library
16
+ # ---------------------------------------------------------------------------
17
+ import ensurepip
18
+ import importlib
19
+ import importlib.metadata
20
+ import importlib.util
21
+ import subprocess
22
+ import sys
23
+
24
+ from absfuyu.core.baseclass import BaseClass
25
+
26
+
27
+ # Class
28
+ # ---------------------------------------------------------------------------
29
+ class PackageManager(BaseClass):
30
+ """
31
+ Utility class for checking, installing, and importing Python packages safely.
32
+ """
33
+
34
+ def __init__(
35
+ self,
36
+ package: str,
37
+ import_name: str | None = None,
38
+ auto_upgrade: bool = False,
39
+ auto_bootstrap: bool = True,
40
+ ) -> None:
41
+ """
42
+ A configurable package manager utility that can check, install, and import Python packages safely.
43
+
44
+ Parameters
45
+ ----------
46
+ package : str
47
+ The pip package name (e.g. "absfuyu", "random").
48
+
49
+ import_name : str | None
50
+ The importable module name if different from the package name (e.g. "PIL" for "pillow").
51
+
52
+ auto_upgrade : bool, by default ``False``
53
+ Whether to automatically upgrade packages during installation.
54
+
55
+ auto_bootstrap : bool, by default ``True``
56
+ Whether to automatically bootstrap pip using ensurepip if it's missing.
57
+ """
58
+ self.package = package
59
+ self.import_name = import_name
60
+ self.auto_upgrade = auto_upgrade
61
+ self.auto_bootstrap = auto_bootstrap
62
+
63
+ @property
64
+ def version(self) -> str | None:
65
+ """
66
+ Version of package if available
67
+
68
+ Returns
69
+ -------
70
+ str
71
+ Version of package
72
+
73
+ None
74
+ When package is not available
75
+ """
76
+ try:
77
+ return importlib.metadata.version(self.package or self.import_name)
78
+ except importlib.metadata.PackageNotFoundError:
79
+ return None
80
+
81
+ def _run_pip_install(self, package: str) -> None:
82
+ """
83
+ Internal helper to safely run pip install, bootstrapping pip if needed.
84
+ """
85
+ try:
86
+ import pip # noqa: F401
87
+ except ImportError:
88
+ if self.auto_bootstrap:
89
+ ensurepip.bootstrap()
90
+ else:
91
+ raise RuntimeError("pip not found and auto_bootstrap is disabled.")
92
+
93
+ cmd = [sys.executable, "-m", "pip", "install", package]
94
+ if self.auto_upgrade:
95
+ cmd.append("--upgrade")
96
+
97
+ try:
98
+ subprocess.check_call(cmd)
99
+ except subprocess.CalledProcessError as e:
100
+ raise RuntimeError(f"Failed to install {package}: {e}")
101
+
102
+ def ensure_installed(self) -> None:
103
+ """
104
+ Ensure a Python package is installed. Installs (and optionally upgrades) it if missing.
105
+ """
106
+ module_name = self.import_name or self.package
107
+
108
+ if importlib.util.find_spec(module_name) is None:
109
+ self._run_pip_install(self.package)
110
+
111
+ def ensure_import(self):
112
+ """
113
+ Ensure a Python package is importable, installing it if necessary.
114
+ Returns the imported module.
115
+ """
116
+ module_name = self.import_name or self.package
117
+
118
+ if importlib.util.find_spec(module_name) is not None:
119
+ return importlib.import_module(module_name)
120
+
121
+ self.logger.info(f"Installing missing package: {self.package} ...")
122
+
123
+ self._run_pip_install(self.package)
124
+ return importlib.import_module(module_name)