absfuyu 5.0.0__py3-none-any.whl → 5.1.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.
- absfuyu/__init__.py +1 -1
- absfuyu/__main__.py +2 -2
- absfuyu/cli/__init__.py +2 -2
- absfuyu/cli/color.py +30 -14
- absfuyu/cli/config_group.py +9 -2
- absfuyu/cli/do_group.py +13 -6
- absfuyu/cli/game_group.py +9 -2
- absfuyu/cli/tool_group.py +16 -9
- absfuyu/config/__init__.py +2 -2
- absfuyu/core/__init__.py +2 -2
- absfuyu/core/baseclass.py +449 -80
- absfuyu/core/baseclass2.py +2 -2
- absfuyu/core/decorator.py +69 -3
- absfuyu/core/docstring.py +25 -22
- absfuyu/core/dummy_cli.py +2 -2
- absfuyu/core/dummy_func.py +19 -6
- absfuyu/core/typings.py +40 -0
- absfuyu/dxt/__init__.py +2 -2
- absfuyu/dxt/dictext.py +2 -2
- absfuyu/dxt/dxt_support.py +2 -2
- absfuyu/dxt/intext.py +31 -3
- absfuyu/dxt/listext.py +28 -3
- absfuyu/dxt/strext.py +3 -3
- absfuyu/extra/__init__.py +2 -2
- absfuyu/extra/beautiful.py +3 -2
- absfuyu/extra/da/__init__.py +36 -0
- absfuyu/extra/da/dadf.py +1138 -0
- absfuyu/extra/da/dadf_base.py +186 -0
- absfuyu/extra/da/df_func.py +97 -0
- absfuyu/extra/da/mplt.py +219 -0
- absfuyu/extra/data_analysis.py +10 -1067
- absfuyu/fun/__init__.py +2 -2
- absfuyu/fun/tarot.py +2 -2
- absfuyu/game/__init__.py +2 -2
- absfuyu/game/game_stat.py +2 -2
- absfuyu/game/sudoku.py +2 -2
- absfuyu/game/tictactoe.py +2 -2
- absfuyu/game/wordle.py +2 -2
- absfuyu/general/__init__.py +4 -4
- absfuyu/general/content.py +2 -2
- absfuyu/general/human.py +2 -2
- absfuyu/general/shape.py +2 -2
- absfuyu/logger.py +2 -2
- absfuyu/pkg_data/__init__.py +2 -2
- absfuyu/pkg_data/deprecated.py +2 -2
- absfuyu/sort.py +2 -2
- absfuyu/tools/__init__.py +25 -2
- absfuyu/tools/checksum.py +27 -7
- absfuyu/tools/converter.py +93 -28
- absfuyu/{general → tools}/generator.py +2 -2
- absfuyu/tools/inspector.py +433 -0
- absfuyu/tools/keygen.py +2 -2
- absfuyu/tools/obfuscator.py +46 -8
- absfuyu/tools/passwordlib.py +88 -23
- absfuyu/tools/shutdownizer.py +2 -2
- absfuyu/tools/web.py +2 -2
- absfuyu/util/__init__.py +2 -2
- absfuyu/util/api.py +2 -2
- absfuyu/util/json_method.py +2 -2
- absfuyu/util/lunar.py +2 -2
- absfuyu/util/path.py +190 -82
- absfuyu/util/performance.py +4 -4
- absfuyu/util/shorten_number.py +40 -10
- absfuyu/util/text_table.py +272 -0
- absfuyu/util/zipped.py +6 -6
- absfuyu/version.py +59 -42
- {absfuyu-5.0.0.dist-info → absfuyu-5.1.0.dist-info}/METADATA +10 -3
- absfuyu-5.1.0.dist-info/RECORD +76 -0
- absfuyu-5.0.0.dist-info/RECORD +0 -68
- {absfuyu-5.0.0.dist-info → absfuyu-5.1.0.dist-info}/WHEEL +0 -0
- {absfuyu-5.0.0.dist-info → absfuyu-5.1.0.dist-info}/entry_points.txt +0 -0
- {absfuyu-5.0.0.dist-info → absfuyu-5.1.0.dist-info}/licenses/LICENSE +0 -0
absfuyu/util/performance.py
CHANGED
|
@@ -3,8 +3,8 @@ Absfuyu: Performance
|
|
|
3
3
|
--------------------
|
|
4
4
|
Performance Check
|
|
5
5
|
|
|
6
|
-
Version: 5.
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 5.1.0
|
|
7
|
+
Date updated: 10/03/2025 (dd/mm/yyyy)
|
|
8
8
|
|
|
9
9
|
Feature:
|
|
10
10
|
--------
|
|
@@ -36,7 +36,7 @@ from functools import wraps
|
|
|
36
36
|
from inspect import getsource
|
|
37
37
|
from typing import Any, ParamSpec, TypeVar
|
|
38
38
|
|
|
39
|
-
from absfuyu.core import versionadded, versionchanged
|
|
39
|
+
from absfuyu.core import deprecated, versionadded, versionchanged
|
|
40
40
|
from absfuyu.dxt import ListNoDunder
|
|
41
41
|
|
|
42
42
|
# Type
|
|
@@ -225,7 +225,7 @@ def retry(retries: int, delay: float = 1):
|
|
|
225
225
|
|
|
226
226
|
# Class
|
|
227
227
|
# ---------------------------------------------------------------------------
|
|
228
|
-
|
|
228
|
+
@deprecated("5.1.0", reason="Use `absfuyu.tools.inspector` instead")
|
|
229
229
|
class Checker:
|
|
230
230
|
"""
|
|
231
231
|
Check a variable
|
absfuyu/util/shorten_number.py
CHANGED
|
@@ -3,8 +3,8 @@ Absfuyu: Shorten number
|
|
|
3
3
|
-----------------------
|
|
4
4
|
Short number base on suffixes
|
|
5
5
|
|
|
6
|
-
Version: 5.
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 5.1.0
|
|
7
|
+
Date updated: 10/03/2025 (dd/mm/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
# Module level
|
|
@@ -156,11 +156,28 @@ class Decimal:
|
|
|
156
156
|
"""
|
|
157
157
|
Shorten large number
|
|
158
158
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
Parameters
|
|
160
|
+
----------
|
|
161
|
+
original_value : int | float
|
|
162
|
+
Value to shorten
|
|
163
|
+
|
|
164
|
+
base : int
|
|
165
|
+
Short by base (must be > 0)
|
|
166
|
+
|
|
167
|
+
suffixes : list[str]
|
|
168
|
+
List of suffixes to use (ascending order)
|
|
169
|
+
|
|
170
|
+
factory : UnitSuffixFactory | None
|
|
171
|
+
``UnitSuffixFactory`` to use
|
|
172
|
+
(will overwrite ``base`` and ``suffixes``)
|
|
173
|
+
|
|
174
|
+
suffix_full_name : bool
|
|
175
|
+
Use suffix full name (available with ``UnitSuffixFactory``), by default ``False``
|
|
176
|
+
|
|
177
|
+
Returns
|
|
178
|
+
-------
|
|
179
|
+
Decimal
|
|
180
|
+
Decimal instance
|
|
164
181
|
"""
|
|
165
182
|
|
|
166
183
|
original_value: int | float = field(repr=False)
|
|
@@ -173,6 +190,7 @@ class Decimal:
|
|
|
173
190
|
suffix: str = field(init=False)
|
|
174
191
|
|
|
175
192
|
def __post_init__(self) -> None:
|
|
193
|
+
self.base = max(1, self.base) # Make sure that base >= 1
|
|
176
194
|
self._get_factory()
|
|
177
195
|
self.value, self.suffix = self._convert_decimal()
|
|
178
196
|
|
|
@@ -228,9 +246,21 @@ class Decimal:
|
|
|
228
246
|
"""
|
|
229
247
|
Convert to string
|
|
230
248
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
249
|
+
Parameters
|
|
250
|
+
----------
|
|
251
|
+
decimal : int, optional
|
|
252
|
+
Round up to which decimal, by default ``2``
|
|
253
|
+
|
|
254
|
+
separator : str, optional
|
|
255
|
+
Character between value and suffix, by default ``" "``
|
|
256
|
+
|
|
257
|
+
float_only : bool, optional
|
|
258
|
+
Returns value as <float> instead of <int> when ``decimal = 0``, by default ``True``
|
|
259
|
+
|
|
260
|
+
Returns
|
|
261
|
+
-------
|
|
262
|
+
str
|
|
263
|
+
Decimal string
|
|
234
264
|
"""
|
|
235
265
|
val = self.value.__round__(decimal)
|
|
236
266
|
formatted_value = f"{val:,}"
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Absufyu: Utilities
|
|
3
|
+
------------------
|
|
4
|
+
Text table
|
|
5
|
+
|
|
6
|
+
Version: 5.1.0
|
|
7
|
+
Date updated: 10/03/2025 (dd/mm/yyyy)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# Module level
|
|
11
|
+
# ---------------------------------------------------------------------------
|
|
12
|
+
__all__ = ["OneColumnTableMaker"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# Library
|
|
16
|
+
# ---------------------------------------------------------------------------
|
|
17
|
+
import os
|
|
18
|
+
from collections.abc import Sequence
|
|
19
|
+
from enum import StrEnum
|
|
20
|
+
from textwrap import TextWrapper
|
|
21
|
+
from typing import Literal
|
|
22
|
+
|
|
23
|
+
from absfuyu.core import BaseClass
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Style
|
|
27
|
+
# ---------------------------------------------------------------------------
|
|
28
|
+
class BoxDrawingCharacter(StrEnum):
|
|
29
|
+
"""
|
|
30
|
+
Box drawing characters - Normal
|
|
31
|
+
|
|
32
|
+
Characters reference: https://en.wikipedia.org/wiki/Box-drawing_characters
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
UPPER_LEFT_CORNER = "\u250c"
|
|
36
|
+
UPPER_RIGHT_CORNER = "\u2510"
|
|
37
|
+
HORIZONTAL = "\u2500"
|
|
38
|
+
VERTICAL = "\u2502"
|
|
39
|
+
LOWER_LEFT_CORNER = "\u2514"
|
|
40
|
+
LOWER_RIGHT_CORNER = "\u2518"
|
|
41
|
+
VERTICAL_RIGHT = "\u251c"
|
|
42
|
+
VERTICAL_LEFT = "\u2524"
|
|
43
|
+
CROSS = "\u253c"
|
|
44
|
+
HORIZONTAL_UP = "\u2534"
|
|
45
|
+
HORIZONTAL_DOWN = "\u252c"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class BoxDrawingCharacterBold(StrEnum):
|
|
49
|
+
"""
|
|
50
|
+
Box drawing characters - Bold
|
|
51
|
+
|
|
52
|
+
Characters reference: https://en.wikipedia.org/wiki/Box-drawing_characters
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
UPPER_LEFT_CORNER = "\u250f"
|
|
56
|
+
UPPER_RIGHT_CORNER = "\u2513"
|
|
57
|
+
HORIZONTAL = "\u2501"
|
|
58
|
+
VERTICAL = "\u2503"
|
|
59
|
+
LOWER_LEFT_CORNER = "\u2517"
|
|
60
|
+
LOWER_RIGHT_CORNER = "\u251b"
|
|
61
|
+
VERTICAL_RIGHT = "\u2523"
|
|
62
|
+
VERTICAL_LEFT = "\u252b"
|
|
63
|
+
CROSS = "\u254b"
|
|
64
|
+
HORIZONTAL_UP = "\u253b"
|
|
65
|
+
HORIZONTAL_DOWN = "\u2533"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class BoxDrawingCharacterDashed(StrEnum):
|
|
69
|
+
"""
|
|
70
|
+
Box drawing characters - Dashed
|
|
71
|
+
|
|
72
|
+
Characters reference: https://en.wikipedia.org/wiki/Box-drawing_characters
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
UPPER_LEFT_CORNER = "\u250c"
|
|
76
|
+
UPPER_RIGHT_CORNER = "\u2510"
|
|
77
|
+
HORIZONTAL = "\u254c"
|
|
78
|
+
VERTICAL = "\u254e"
|
|
79
|
+
LOWER_LEFT_CORNER = "\u2514"
|
|
80
|
+
LOWER_RIGHT_CORNER = "\u2518"
|
|
81
|
+
VERTICAL_RIGHT = "\u251c"
|
|
82
|
+
VERTICAL_LEFT = "\u2524"
|
|
83
|
+
CROSS = "\u253c"
|
|
84
|
+
HORIZONTAL_UP = "\u2534"
|
|
85
|
+
HORIZONTAL_DOWN = "\u252c"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class BoxDrawingCharacterDouble(StrEnum):
|
|
89
|
+
"""
|
|
90
|
+
Box drawing characters - Double
|
|
91
|
+
|
|
92
|
+
Characters reference: https://en.wikipedia.org/wiki/Box-drawing_characters
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
UPPER_LEFT_CORNER = "\u2554"
|
|
96
|
+
UPPER_RIGHT_CORNER = "\u2557"
|
|
97
|
+
HORIZONTAL = "\u2550"
|
|
98
|
+
VERTICAL = "\u2551"
|
|
99
|
+
LOWER_LEFT_CORNER = "\u255a"
|
|
100
|
+
LOWER_RIGHT_CORNER = "\u255d"
|
|
101
|
+
VERTICAL_RIGHT = "\u2560"
|
|
102
|
+
VERTICAL_LEFT = "\u2563"
|
|
103
|
+
CROSS = "\u256c"
|
|
104
|
+
HORIZONTAL_UP = "\u2569"
|
|
105
|
+
HORIZONTAL_DOWN = "\u2566"
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# Class
|
|
109
|
+
# ---------------------------------------------------------------------------
|
|
110
|
+
class OneColumnTableMaker(BaseClass):
|
|
111
|
+
"""
|
|
112
|
+
Table Maker instance
|
|
113
|
+
|
|
114
|
+
Parameters
|
|
115
|
+
----------
|
|
116
|
+
ncols : int | None, optional
|
|
117
|
+
Length of the table (include content). Must be >= 5.
|
|
118
|
+
Set to ``None`` to use maximum length,
|
|
119
|
+
defaults to ``88`` when failed to use ``os.get_terminal_size()``.
|
|
120
|
+
By default ``None``
|
|
121
|
+
|
|
122
|
+
style : Literal["normal", "bold", "dashed", "double"], optional
|
|
123
|
+
Style for the table, by default ``"normal"``
|
|
124
|
+
"""
|
|
125
|
+
|
|
126
|
+
__slots__ = ("ncols", "_title", "_paragraphs", "_table_char", "_text_wrapper")
|
|
127
|
+
|
|
128
|
+
def __init__(
|
|
129
|
+
self,
|
|
130
|
+
ncols: int | None = None,
|
|
131
|
+
style: Literal["normal", "bold", "dashed", "double"] = "normal",
|
|
132
|
+
) -> None:
|
|
133
|
+
"""
|
|
134
|
+
Table Maker instance
|
|
135
|
+
|
|
136
|
+
Parameters
|
|
137
|
+
----------
|
|
138
|
+
ncols : int | None, optional
|
|
139
|
+
Length of the table (include content). Must be >= 5.
|
|
140
|
+
Set to ``None`` to use maximum length,
|
|
141
|
+
defaults to ``88`` when failed to use ``os.get_terminal_size()``.
|
|
142
|
+
By default ``None``
|
|
143
|
+
|
|
144
|
+
style : Literal["normal", "bold", "dashed", "double"], optional
|
|
145
|
+
Style for the table, by default ``"normal"``
|
|
146
|
+
"""
|
|
147
|
+
|
|
148
|
+
# Text length
|
|
149
|
+
if ncols is None:
|
|
150
|
+
try:
|
|
151
|
+
self.ncols = os.get_terminal_size().columns
|
|
152
|
+
except OSError:
|
|
153
|
+
self.ncols = 88
|
|
154
|
+
else:
|
|
155
|
+
self.ncols = max(5, ncols)
|
|
156
|
+
|
|
157
|
+
# Title & paragraph
|
|
158
|
+
self._title = ""
|
|
159
|
+
self._paragraphs: list[Sequence[str]] = []
|
|
160
|
+
|
|
161
|
+
# Style
|
|
162
|
+
if style == "normal":
|
|
163
|
+
self._table_char = BoxDrawingCharacter
|
|
164
|
+
elif style == "bold":
|
|
165
|
+
self._table_char = BoxDrawingCharacterBold # type: ignore
|
|
166
|
+
elif style == "dashed":
|
|
167
|
+
self._table_char = BoxDrawingCharacterDashed # type: ignore
|
|
168
|
+
elif style == "double":
|
|
169
|
+
self._table_char = BoxDrawingCharacterDouble # type: ignore
|
|
170
|
+
else:
|
|
171
|
+
self._table_char = BoxDrawingCharacter # type: ignore
|
|
172
|
+
|
|
173
|
+
# Text wrapper
|
|
174
|
+
self._text_wrapper = TextWrapper(
|
|
175
|
+
width=self.ncols - 4,
|
|
176
|
+
initial_indent="",
|
|
177
|
+
subsequent_indent="",
|
|
178
|
+
tabsize=4,
|
|
179
|
+
break_long_words=True,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
def add_title(self, title: str) -> None:
|
|
183
|
+
"""
|
|
184
|
+
Add title to Table
|
|
185
|
+
|
|
186
|
+
Parameters
|
|
187
|
+
----------
|
|
188
|
+
title : str
|
|
189
|
+
Title to add.
|
|
190
|
+
When ``len(title) > ncols``: title will not show
|
|
191
|
+
"""
|
|
192
|
+
max_padding_length = self.ncols - 2
|
|
193
|
+
if max_padding_length < (len(title) + 2) or len(title) < 1:
|
|
194
|
+
_title = ""
|
|
195
|
+
else:
|
|
196
|
+
_title = f" {title} "
|
|
197
|
+
|
|
198
|
+
line = (
|
|
199
|
+
f"{self._table_char.UPPER_LEFT_CORNER}"
|
|
200
|
+
f"{_title.center(max_padding_length, self._table_char.HORIZONTAL)}"
|
|
201
|
+
f"{self._table_char.UPPER_RIGHT_CORNER}"
|
|
202
|
+
)
|
|
203
|
+
self._title = line
|
|
204
|
+
|
|
205
|
+
def add_paragraph(self, paragraph: Sequence[str]) -> None:
|
|
206
|
+
"""
|
|
207
|
+
Add paragraph into Table
|
|
208
|
+
|
|
209
|
+
Parameters
|
|
210
|
+
----------
|
|
211
|
+
paragraph : Sequence[str]
|
|
212
|
+
An iterable of str
|
|
213
|
+
"""
|
|
214
|
+
if isinstance(paragraph, str):
|
|
215
|
+
self._paragraphs.append([paragraph])
|
|
216
|
+
else:
|
|
217
|
+
self._paragraphs.append(paragraph)
|
|
218
|
+
|
|
219
|
+
def _make_line(self, option: Literal[0, 1, 2]) -> str:
|
|
220
|
+
options = (
|
|
221
|
+
(self._table_char.UPPER_LEFT_CORNER, self._table_char.UPPER_RIGHT_CORNER),
|
|
222
|
+
(self._table_char.VERTICAL_RIGHT, self._table_char.VERTICAL_LEFT),
|
|
223
|
+
(self._table_char.LOWER_LEFT_CORNER, self._table_char.LOWER_RIGHT_CORNER),
|
|
224
|
+
)
|
|
225
|
+
max_line_length = self.ncols - 2
|
|
226
|
+
line = (
|
|
227
|
+
f"{options[option][0]}"
|
|
228
|
+
f"{''.ljust(max_line_length, self._table_char.HORIZONTAL)}"
|
|
229
|
+
f"{options[option][1]}"
|
|
230
|
+
)
|
|
231
|
+
return line
|
|
232
|
+
|
|
233
|
+
def _make_table(self) -> list[str] | None:
|
|
234
|
+
# Check if empty
|
|
235
|
+
if len(self._paragraphs) < 1:
|
|
236
|
+
return None
|
|
237
|
+
if len(self._paragraphs[0]) < 1:
|
|
238
|
+
return None
|
|
239
|
+
|
|
240
|
+
# Make table
|
|
241
|
+
max_content_length = self.ncols - 4
|
|
242
|
+
paragraph_length = len(self._paragraphs)
|
|
243
|
+
|
|
244
|
+
# Line prep
|
|
245
|
+
_first_line = self._make_line(0)
|
|
246
|
+
_sep_line = self._make_line(1)
|
|
247
|
+
_last_line = self._make_line(2)
|
|
248
|
+
|
|
249
|
+
# Table
|
|
250
|
+
table: list[str] = [_first_line] if self._title == "" else [self._title]
|
|
251
|
+
for i, paragraph in enumerate(self._paragraphs, start=1):
|
|
252
|
+
for line in paragraph:
|
|
253
|
+
splitted_line = self._text_wrapper.wrap(line) if len(line) > 0 else [""]
|
|
254
|
+
mod_lines: list[str] = [
|
|
255
|
+
f"{self._table_char.VERTICAL} "
|
|
256
|
+
f"{line.ljust(max_content_length, ' ')}"
|
|
257
|
+
f" {self._table_char.VERTICAL}"
|
|
258
|
+
for line in splitted_line
|
|
259
|
+
]
|
|
260
|
+
table.extend(mod_lines)
|
|
261
|
+
|
|
262
|
+
if i != paragraph_length:
|
|
263
|
+
table.append(_sep_line)
|
|
264
|
+
else:
|
|
265
|
+
table.append(_last_line)
|
|
266
|
+
return table
|
|
267
|
+
|
|
268
|
+
def make_table(self) -> str:
|
|
269
|
+
table = self._make_table()
|
|
270
|
+
if table is None:
|
|
271
|
+
return ""
|
|
272
|
+
return "\n".join(table)
|
absfuyu/util/zipped.py
CHANGED
|
@@ -3,15 +3,13 @@ Absfuyu: Zipped
|
|
|
3
3
|
---------------
|
|
4
4
|
Zipping stuff (deprecated soon, most features already in absfuyu.util.path.Directory)
|
|
5
5
|
|
|
6
|
-
Version:
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 5.1.0
|
|
7
|
+
Date updated: 10/03/2025 (dd/mm/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
# Module level
|
|
11
11
|
# ---------------------------------------------------------------------------
|
|
12
|
-
__all__ = [
|
|
13
|
-
"Zipper",
|
|
14
|
-
]
|
|
12
|
+
__all__ = ["Zipper"]
|
|
15
13
|
|
|
16
14
|
|
|
17
15
|
# Library
|
|
@@ -20,11 +18,13 @@ import shutil
|
|
|
20
18
|
import zipfile
|
|
21
19
|
from pathlib import Path
|
|
22
20
|
|
|
23
|
-
from absfuyu.core import BaseClass, versionadded
|
|
21
|
+
from absfuyu.core import BaseClass, deprecated, versionadded
|
|
24
22
|
from absfuyu.logger import logger
|
|
25
23
|
|
|
26
24
|
|
|
25
|
+
# Class
|
|
27
26
|
# ---------------------------------------------------------------------------
|
|
27
|
+
@deprecated("5.1.0", reason="Use ``absfuyu.util.path.Directory`` instead")
|
|
28
28
|
class Zipper(BaseClass):
|
|
29
29
|
"""Zip file or folder"""
|
|
30
30
|
|
absfuyu/version.py
CHANGED
|
@@ -3,10 +3,12 @@ Absfuyu: Version
|
|
|
3
3
|
----------------
|
|
4
4
|
Package versioning module
|
|
5
5
|
|
|
6
|
-
Version:
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 5.1.0
|
|
7
|
+
Date updated: 10/03/2025 (dd/mm/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
+
# Module level
|
|
11
|
+
# ---------------------------------------------------------------------------
|
|
10
12
|
__all__ = [
|
|
11
13
|
# Options
|
|
12
14
|
"ReleaseOption",
|
|
@@ -18,42 +20,50 @@ __all__ = [
|
|
|
18
20
|
]
|
|
19
21
|
|
|
20
22
|
|
|
23
|
+
# Library
|
|
24
|
+
# ---------------------------------------------------------------------------
|
|
21
25
|
import json
|
|
22
26
|
import re
|
|
23
27
|
import subprocess
|
|
24
|
-
from
|
|
28
|
+
from enum import StrEnum
|
|
29
|
+
from typing import Self, TypedDict
|
|
25
30
|
from urllib.error import URLError
|
|
26
31
|
from urllib.request import Request, urlopen
|
|
27
32
|
|
|
33
|
+
from absfuyu.core import BaseClass
|
|
28
34
|
from absfuyu.logger import logger
|
|
29
35
|
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
# Class
|
|
38
|
+
# ---------------------------------------------------------------------------
|
|
39
|
+
class ReleaseOption(StrEnum):
|
|
32
40
|
"""
|
|
33
41
|
``MAJOR``, ``MINOR``, ``PATCH``
|
|
34
42
|
"""
|
|
35
43
|
|
|
36
|
-
MAJOR
|
|
37
|
-
MINOR
|
|
38
|
-
PATCH
|
|
44
|
+
MAJOR = "major"
|
|
45
|
+
MINOR = "minor"
|
|
46
|
+
PATCH = "patch"
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
@classmethod
|
|
49
|
+
def all_option(cls) -> list[str]:
|
|
41
50
|
"""Return a list of release options"""
|
|
42
|
-
return [
|
|
51
|
+
return [cls.MAJOR.value, cls.MINOR.value, cls.PATCH.value]
|
|
43
52
|
|
|
44
53
|
|
|
45
|
-
class ReleaseLevel:
|
|
54
|
+
class ReleaseLevel(StrEnum):
|
|
46
55
|
"""
|
|
47
56
|
``FINAL``, ``DEV``, ``RC``
|
|
48
57
|
"""
|
|
49
58
|
|
|
50
|
-
FINAL
|
|
51
|
-
DEV
|
|
52
|
-
RC
|
|
59
|
+
FINAL = "final"
|
|
60
|
+
DEV = "dev"
|
|
61
|
+
RC = "rc" # Release candidate
|
|
53
62
|
|
|
54
|
-
|
|
63
|
+
@classmethod
|
|
64
|
+
def all_level(cls) -> list[str]:
|
|
55
65
|
"""Return a list of release levels"""
|
|
56
|
-
return [
|
|
66
|
+
return [cls.FINAL.value, cls.DEV.value, cls.RC.value]
|
|
57
67
|
|
|
58
68
|
|
|
59
69
|
class VersionDictFormat(TypedDict):
|
|
@@ -74,30 +84,36 @@ class VersionDictFormat(TypedDict):
|
|
|
74
84
|
serial: int
|
|
75
85
|
|
|
76
86
|
|
|
77
|
-
class Version:
|
|
87
|
+
class Version(BaseClass):
|
|
78
88
|
"""Version"""
|
|
79
89
|
|
|
80
90
|
def __init__(
|
|
81
91
|
self,
|
|
82
|
-
major:
|
|
83
|
-
minor:
|
|
84
|
-
patch:
|
|
92
|
+
major: int | str,
|
|
93
|
+
minor: int | str,
|
|
94
|
+
patch: int | str,
|
|
85
95
|
release_level: str = ReleaseLevel.FINAL,
|
|
86
|
-
serial:
|
|
96
|
+
serial: int | str = 0,
|
|
87
97
|
) -> None:
|
|
88
98
|
"""
|
|
89
99
|
Create ``Version`` instance
|
|
90
100
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
Parameters
|
|
102
|
+
----------
|
|
103
|
+
major : int | str
|
|
104
|
+
Major change
|
|
105
|
+
|
|
106
|
+
minor : int | str
|
|
107
|
+
Minor change
|
|
108
|
+
|
|
109
|
+
patch : int | str
|
|
110
|
+
Patch
|
|
111
|
+
|
|
112
|
+
release_level : str, optional
|
|
113
|
+
Release level: ``final`` | ``rc`` | ``dev``, by default ``ReleaseLevel.FINAL``
|
|
114
|
+
|
|
115
|
+
serial : int | str, optional
|
|
116
|
+
Serial for release level ``rc`` | ``dev``, by default ``0``
|
|
101
117
|
"""
|
|
102
118
|
self.major: int = major if isinstance(major, int) else int(major)
|
|
103
119
|
self.minor: int = minor if isinstance(minor, int) else int(minor)
|
|
@@ -108,15 +124,16 @@ class Version:
|
|
|
108
124
|
def __str__(self) -> str:
|
|
109
125
|
return self.version
|
|
110
126
|
|
|
111
|
-
def __repr__(self) -> str:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
# def __repr__(self) -> str:
|
|
128
|
+
# cls_name = self.__class__.__name__
|
|
129
|
+
# if self.release_level.startswith(ReleaseLevel.FINAL):
|
|
130
|
+
# return f"{cls_name}(major={self.major}, minor={self.minor}, patch={self.patch})"
|
|
131
|
+
# else:
|
|
132
|
+
# return (
|
|
133
|
+
# f"{cls_name}("
|
|
134
|
+
# f"major={self.major}, minor={self.minor}, patch={self.patch}, "
|
|
135
|
+
# f"release_level={self.release_level}, serial={self.serial})"
|
|
136
|
+
# )
|
|
120
137
|
|
|
121
138
|
def __format__(self, format_spec: str) -> str:
|
|
122
139
|
"""
|
|
@@ -166,8 +183,8 @@ class Version:
|
|
|
166
183
|
|
|
167
184
|
@classmethod
|
|
168
185
|
def from_tuple(
|
|
169
|
-
cls, iterable:
|
|
170
|
-
):
|
|
186
|
+
cls, iterable: tuple[int, int, int] | tuple[int, int, int, str, int]
|
|
187
|
+
) -> Self:
|
|
171
188
|
"""
|
|
172
189
|
Convert to ``Version`` from a ``tuple``
|
|
173
190
|
|
|
@@ -203,7 +220,7 @@ class Version:
|
|
|
203
220
|
raise ValueError("iterable must have len of 5 or 3")
|
|
204
221
|
|
|
205
222
|
@classmethod
|
|
206
|
-
def from_str(cls, version_string: str):
|
|
223
|
+
def from_str(cls, version_string: str) -> Self:
|
|
207
224
|
"""
|
|
208
225
|
Convert to ``Version`` from a ``str``
|
|
209
226
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: absfuyu
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.1.0
|
|
4
4
|
Summary: A small collection of code
|
|
5
5
|
Project-URL: Homepage, https://github.com/AbsoluteWinter/absfuyu-public
|
|
6
6
|
Project-URL: Documentation, https://absolutewinter.github.io/absfuyu-docs/
|
|
@@ -86,7 +86,7 @@ help(absfuyu)
|
|
|
86
86
|
|
|
87
87
|
### Notable features
|
|
88
88
|
|
|
89
|
-
**absfuyu.core**: Provides
|
|
89
|
+
**absfuyu.core**: Provides base components for additional functionalities.
|
|
90
90
|
|
|
91
91
|
```python
|
|
92
92
|
# Decorators that adds info to __doc__
|
|
@@ -104,13 +104,20 @@ for x in [DictExt, IntExt, ListExt, Text]:
|
|
|
104
104
|
x.show_all_methods(print_result=1)
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
+
**absfuyu.tools.Inspector**: An object inspector
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from absfuyu.tools import Inspector
|
|
111
|
+
print(Inspector(Inspector))
|
|
112
|
+
```
|
|
113
|
+
|
|
107
114
|
There are many additional features available to explore.
|
|
108
115
|
|
|
109
116
|
## **DOCUMENTATION:**
|
|
110
117
|
|
|
111
118
|
For more detailed information about the project, please refer to the documentation available at the following link:
|
|
112
119
|
|
|
113
|
-
> [Project Documentation](https://absolutewinter.github.io/absfuyu/)
|
|
120
|
+
> [Project Documentation](https://absolutewinter.github.io/absfuyu-docs/)
|
|
114
121
|
|
|
115
122
|
## **DEVELOPMENT SETUP**
|
|
116
123
|
|