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.
- absfuyu/__init__.py +5 -3
- absfuyu/__main__.py +3 -3
- absfuyu/cli/__init__.py +13 -2
- absfuyu/cli/audio_group.py +98 -0
- absfuyu/cli/color.py +30 -14
- absfuyu/cli/config_group.py +9 -2
- absfuyu/cli/do_group.py +23 -6
- absfuyu/cli/game_group.py +27 -2
- absfuyu/cli/tool_group.py +81 -11
- absfuyu/config/__init__.py +3 -3
- absfuyu/core/__init__.py +12 -8
- absfuyu/core/baseclass.py +929 -96
- absfuyu/core/baseclass2.py +44 -3
- absfuyu/core/decorator.py +70 -4
- absfuyu/core/docstring.py +64 -41
- absfuyu/core/dummy_cli.py +3 -3
- absfuyu/core/dummy_func.py +19 -6
- absfuyu/dxt/__init__.py +2 -2
- absfuyu/dxt/base_type.py +93 -0
- absfuyu/dxt/dictext.py +204 -16
- absfuyu/dxt/dxt_support.py +2 -2
- absfuyu/dxt/intext.py +151 -34
- absfuyu/dxt/listext.py +969 -127
- absfuyu/dxt/strext.py +77 -17
- absfuyu/extra/__init__.py +2 -2
- absfuyu/extra/audio/__init__.py +8 -0
- absfuyu/extra/audio/_util.py +57 -0
- absfuyu/extra/audio/convert.py +192 -0
- absfuyu/extra/audio/lossless.py +281 -0
- absfuyu/extra/beautiful.py +3 -2
- absfuyu/extra/da/__init__.py +72 -0
- absfuyu/extra/da/dadf.py +1600 -0
- absfuyu/extra/da/dadf_base.py +186 -0
- absfuyu/extra/da/df_func.py +181 -0
- absfuyu/extra/da/mplt.py +219 -0
- absfuyu/extra/ggapi/__init__.py +8 -0
- absfuyu/extra/ggapi/gdrive.py +223 -0
- absfuyu/extra/ggapi/glicense.py +148 -0
- absfuyu/extra/ggapi/glicense_df.py +186 -0
- absfuyu/extra/ggapi/gsheet.py +88 -0
- absfuyu/extra/img/__init__.py +30 -0
- absfuyu/extra/img/converter.py +402 -0
- absfuyu/extra/img/dup_check.py +291 -0
- absfuyu/extra/pdf.py +87 -0
- absfuyu/extra/rclone.py +253 -0
- absfuyu/extra/xml.py +90 -0
- absfuyu/fun/__init__.py +7 -20
- absfuyu/fun/rubik.py +442 -0
- absfuyu/fun/tarot.py +2 -2
- absfuyu/game/__init__.py +2 -2
- absfuyu/game/game_stat.py +2 -2
- absfuyu/game/schulte.py +78 -0
- absfuyu/game/sudoku.py +2 -2
- absfuyu/game/tictactoe.py +2 -3
- absfuyu/game/wordle.py +6 -4
- absfuyu/general/__init__.py +4 -4
- absfuyu/general/content.py +4 -4
- absfuyu/general/human.py +2 -2
- absfuyu/general/resrel.py +213 -0
- absfuyu/general/shape.py +3 -8
- absfuyu/general/tax.py +344 -0
- absfuyu/logger.py +806 -59
- absfuyu/numbers/__init__.py +13 -0
- absfuyu/numbers/number_to_word.py +321 -0
- absfuyu/numbers/shorten_number.py +303 -0
- absfuyu/numbers/time_duration.py +217 -0
- absfuyu/pkg_data/__init__.py +2 -2
- absfuyu/pkg_data/deprecated.py +2 -2
- absfuyu/pkg_data/logo.py +1462 -0
- absfuyu/sort.py +4 -4
- absfuyu/tools/__init__.py +28 -2
- absfuyu/tools/checksum.py +144 -9
- absfuyu/tools/converter.py +120 -34
- absfuyu/tools/generator.py +461 -0
- absfuyu/tools/inspector.py +752 -0
- absfuyu/tools/keygen.py +2 -2
- absfuyu/tools/obfuscator.py +47 -9
- absfuyu/tools/passwordlib.py +89 -25
- absfuyu/tools/shutdownizer.py +3 -8
- absfuyu/tools/sw.py +718 -0
- absfuyu/tools/web.py +10 -13
- absfuyu/typings.py +138 -0
- absfuyu/util/__init__.py +114 -6
- absfuyu/util/api.py +41 -18
- absfuyu/util/cli.py +119 -0
- absfuyu/util/gui.py +91 -0
- absfuyu/util/json_method.py +43 -14
- absfuyu/util/lunar.py +2 -2
- absfuyu/util/package.py +124 -0
- absfuyu/util/path.py +702 -82
- absfuyu/util/performance.py +122 -7
- absfuyu/util/shorten_number.py +244 -21
- absfuyu/util/text_table.py +481 -0
- absfuyu/util/zipped.py +8 -7
- absfuyu/version.py +79 -59
- {absfuyu-5.0.0.dist-info → absfuyu-6.1.2.dist-info}/METADATA +52 -11
- absfuyu-6.1.2.dist-info/RECORD +105 -0
- {absfuyu-5.0.0.dist-info → absfuyu-6.1.2.dist-info}/WHEEL +1 -1
- absfuyu/extra/data_analysis.py +0 -1078
- absfuyu/general/generator.py +0 -303
- absfuyu-5.0.0.dist-info/RECORD +0 -68
- {absfuyu-5.0.0.dist-info → absfuyu-6.1.2.dist-info}/entry_points.txt +0 -0
- {absfuyu-5.0.0.dist-info → absfuyu-6.1.2.dist-info}/licenses/LICENSE +0 -0
absfuyu/util/json_method.py
CHANGED
|
@@ -3,8 +3,8 @@ Absfuyu: Json Method
|
|
|
3
3
|
--------------------
|
|
4
4
|
``.json`` file handling
|
|
5
5
|
|
|
6
|
-
Version:
|
|
7
|
-
Date updated:
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
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
|
|
79
|
+
def load_json(self) -> dict:
|
|
55
80
|
"""
|
|
56
81
|
Load ``.json`` file
|
|
57
82
|
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
98
|
+
def update_data(self, data: dict) -> None:
|
|
72
99
|
"""
|
|
73
100
|
Update ``.json`` data without save
|
|
74
101
|
|
|
75
|
-
|
|
76
|
-
|
|
102
|
+
Parameters
|
|
103
|
+
----------
|
|
104
|
+
data : dict
|
|
105
|
+
``.json`` data
|
|
77
106
|
"""
|
|
78
107
|
self.data = data
|
absfuyu/util/lunar.py
CHANGED
absfuyu/util/package.py
ADDED
|
@@ -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)
|