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
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Absufyu: Utilities
|
|
3
|
+
------------------
|
|
4
|
+
Text table
|
|
5
|
+
|
|
6
|
+
Version: 6.1.1
|
|
7
|
+
Date updated: 30/12/2025 (dd/mm/yyyy)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# Module level
|
|
11
|
+
# ---------------------------------------------------------------------------
|
|
12
|
+
__all__ = ["BoxStyle", "OneColumnTableMaker"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# Library
|
|
16
|
+
# ---------------------------------------------------------------------------
|
|
17
|
+
import os
|
|
18
|
+
from collections.abc import Sequence
|
|
19
|
+
from textwrap import TextWrapper
|
|
20
|
+
from typing import Literal
|
|
21
|
+
|
|
22
|
+
from absfuyu.core import BaseClass
|
|
23
|
+
|
|
24
|
+
# Style
|
|
25
|
+
# ---------------------------------------------------------------------------
|
|
26
|
+
BoxStyle = Literal[
|
|
27
|
+
"normal",
|
|
28
|
+
"bold",
|
|
29
|
+
"dashed",
|
|
30
|
+
"double",
|
|
31
|
+
"rounded",
|
|
32
|
+
"drounded",
|
|
33
|
+
"diamond",
|
|
34
|
+
"dbold",
|
|
35
|
+
"dashed3",
|
|
36
|
+
"dashed4",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class BoxDrawingCharacterBase:
|
|
41
|
+
"""
|
|
42
|
+
Box drawing characters - Base/Normal characters
|
|
43
|
+
|
|
44
|
+
Characters reference: https://en.wikipedia.org/wiki/Box-drawing_characters
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
UPPER_LEFT_CORNER = "\u250c"
|
|
48
|
+
UPPER_RIGHT_CORNER = "\u2510"
|
|
49
|
+
HORIZONTAL = "\u2500"
|
|
50
|
+
VERTICAL = "\u2502"
|
|
51
|
+
LOWER_LEFT_CORNER = "\u2514"
|
|
52
|
+
LOWER_RIGHT_CORNER = "\u2518"
|
|
53
|
+
VERTICAL_RIGHT = "\u251c"
|
|
54
|
+
VERTICAL_LEFT = "\u2524"
|
|
55
|
+
CROSS = "\u253c"
|
|
56
|
+
HORIZONTAL_UP = "\u2534"
|
|
57
|
+
HORIZONTAL_DOWN = "\u252c"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class BoxDrawingCharacterNormal(BoxDrawingCharacterBase):
|
|
61
|
+
"""Normal"""
|
|
62
|
+
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class BoxDrawingCharacterDashed(BoxDrawingCharacterNormal):
|
|
67
|
+
"""Dashed"""
|
|
68
|
+
|
|
69
|
+
HORIZONTAL = "\u254c"
|
|
70
|
+
VERTICAL = "\u254e"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class BoxDrawingCharacterDashed3(BoxDrawingCharacterNormal):
|
|
74
|
+
"""Triple dashed"""
|
|
75
|
+
|
|
76
|
+
HORIZONTAL = "\u2504"
|
|
77
|
+
VERTICAL = "\u2506"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class BoxDrawingCharacterDashed4(BoxDrawingCharacterNormal):
|
|
81
|
+
"""Quadruple dashed"""
|
|
82
|
+
|
|
83
|
+
HORIZONTAL = "\u2508"
|
|
84
|
+
VERTICAL = "\u250a"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class BoxDrawingCharacterRounded(BoxDrawingCharacterNormal):
|
|
88
|
+
"""Rounded"""
|
|
89
|
+
|
|
90
|
+
UPPER_LEFT_CORNER = "\u256d"
|
|
91
|
+
UPPER_RIGHT_CORNER = "\u256e"
|
|
92
|
+
LOWER_LEFT_CORNER = "\u2570"
|
|
93
|
+
LOWER_RIGHT_CORNER = "\u256f"
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class BoxDrawingCharacterDiamond(BoxDrawingCharacterNormal):
|
|
97
|
+
"""Diamond"""
|
|
98
|
+
|
|
99
|
+
UPPER_LEFT_CORNER = "\u2571"
|
|
100
|
+
UPPER_RIGHT_CORNER = "\u2572"
|
|
101
|
+
LOWER_LEFT_CORNER = "\u2572"
|
|
102
|
+
LOWER_RIGHT_CORNER = "\u2571"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class BoxDrawingCharacterDashedRound(
|
|
106
|
+
BoxDrawingCharacterDashed, BoxDrawingCharacterRounded
|
|
107
|
+
):
|
|
108
|
+
"""Dashed rounded"""
|
|
109
|
+
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class BoxDrawingCharacterBold(BoxDrawingCharacterBase):
|
|
114
|
+
"""Bold"""
|
|
115
|
+
|
|
116
|
+
UPPER_LEFT_CORNER = "\u250f"
|
|
117
|
+
UPPER_RIGHT_CORNER = "\u2513"
|
|
118
|
+
HORIZONTAL = "\u2501"
|
|
119
|
+
VERTICAL = "\u2503"
|
|
120
|
+
LOWER_LEFT_CORNER = "\u2517"
|
|
121
|
+
LOWER_RIGHT_CORNER = "\u251b"
|
|
122
|
+
VERTICAL_RIGHT = "\u2523"
|
|
123
|
+
VERTICAL_LEFT = "\u252b"
|
|
124
|
+
CROSS = "\u254b"
|
|
125
|
+
HORIZONTAL_UP = "\u253b"
|
|
126
|
+
HORIZONTAL_DOWN = "\u2533"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class BoxDrawingCharacterDashedBold(BoxDrawingCharacterBold):
|
|
130
|
+
"""Dashed bold"""
|
|
131
|
+
|
|
132
|
+
HORIZONTAL = "\u254d"
|
|
133
|
+
VERTICAL = "\u254f"
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class BoxDrawingCharacterDouble(BoxDrawingCharacterBase):
|
|
137
|
+
"""Double"""
|
|
138
|
+
|
|
139
|
+
UPPER_LEFT_CORNER = "\u2554"
|
|
140
|
+
UPPER_RIGHT_CORNER = "\u2557"
|
|
141
|
+
HORIZONTAL = "\u2550"
|
|
142
|
+
VERTICAL = "\u2551"
|
|
143
|
+
LOWER_LEFT_CORNER = "\u255a"
|
|
144
|
+
LOWER_RIGHT_CORNER = "\u255d"
|
|
145
|
+
VERTICAL_RIGHT = "\u2560"
|
|
146
|
+
VERTICAL_LEFT = "\u2563"
|
|
147
|
+
CROSS = "\u256c"
|
|
148
|
+
HORIZONTAL_UP = "\u2569"
|
|
149
|
+
HORIZONTAL_DOWN = "\u2566"
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def get_box_drawing_character(
|
|
153
|
+
style: BoxStyle | str = "normal",
|
|
154
|
+
) -> type[BoxDrawingCharacterBase]:
|
|
155
|
+
"""
|
|
156
|
+
Choose style for Box drawing characters.
|
|
157
|
+
|
|
158
|
+
Parameters
|
|
159
|
+
----------
|
|
160
|
+
style : BoxStyle | str, optional
|
|
161
|
+
Style for the table, by default ``"normal"``.
|
|
162
|
+
Available style:
|
|
163
|
+
- normal
|
|
164
|
+
- bold
|
|
165
|
+
- dashed
|
|
166
|
+
- double
|
|
167
|
+
- rounded
|
|
168
|
+
- drounded: Dashed and rounded
|
|
169
|
+
- diamond
|
|
170
|
+
- dbold: Bold dashed
|
|
171
|
+
- dashed3: Triple dash
|
|
172
|
+
- dashed4: Quadruple dash
|
|
173
|
+
|
|
174
|
+
Returns
|
|
175
|
+
-------
|
|
176
|
+
BoxDrawingCharacter
|
|
177
|
+
Box drawing characters in specified style.
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
match style.lower().strip():
|
|
181
|
+
case "normal":
|
|
182
|
+
return BoxDrawingCharacterNormal
|
|
183
|
+
case "bold":
|
|
184
|
+
return BoxDrawingCharacterBold
|
|
185
|
+
case "dashed":
|
|
186
|
+
return BoxDrawingCharacterDashed
|
|
187
|
+
case "dashed3":
|
|
188
|
+
return BoxDrawingCharacterDashed3
|
|
189
|
+
case "dashed4":
|
|
190
|
+
return BoxDrawingCharacterDashed4
|
|
191
|
+
case "double":
|
|
192
|
+
return BoxDrawingCharacterDouble
|
|
193
|
+
case "rounded":
|
|
194
|
+
return BoxDrawingCharacterRounded
|
|
195
|
+
case "drounded":
|
|
196
|
+
return BoxDrawingCharacterDashedRound
|
|
197
|
+
case "diamond":
|
|
198
|
+
return BoxDrawingCharacterDiamond
|
|
199
|
+
case "dbold":
|
|
200
|
+
return BoxDrawingCharacterDashedBold
|
|
201
|
+
case _:
|
|
202
|
+
return BoxDrawingCharacterNormal
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
# Class
|
|
206
|
+
# ---------------------------------------------------------------------------
|
|
207
|
+
class OneColumnTableMaker(BaseClass):
|
|
208
|
+
"""
|
|
209
|
+
Table Maker instance
|
|
210
|
+
|
|
211
|
+
Parameters
|
|
212
|
+
----------
|
|
213
|
+
ncols : int | None, optional
|
|
214
|
+
Length of the table (include content). Must be >= 5.
|
|
215
|
+
Set to ``None`` to use maximum length,
|
|
216
|
+
defaults to ``88`` when failed to use ``os.get_terminal_size()``.
|
|
217
|
+
By default ``None``
|
|
218
|
+
|
|
219
|
+
BoxStyle : Literal["normal", "bold", "dashed", "double"], optional
|
|
220
|
+
Style for the table, by default ``"normal"``
|
|
221
|
+
"""
|
|
222
|
+
|
|
223
|
+
__slots__ = ("ncols", "_title", "_paragraphs", "_table_char", "_text_wrapper")
|
|
224
|
+
|
|
225
|
+
def __init__(self, ncols: int | None = None, style: BoxStyle = "normal") -> None:
|
|
226
|
+
"""
|
|
227
|
+
Table Maker instance
|
|
228
|
+
|
|
229
|
+
Parameters
|
|
230
|
+
----------
|
|
231
|
+
ncols : int | None, optional
|
|
232
|
+
Length of the table (include content). Must be >= 5.
|
|
233
|
+
Set to ``None`` to use maximum length,
|
|
234
|
+
defaults to ``88`` when failed to use ``os.get_terminal_size()``.
|
|
235
|
+
By default ``None``
|
|
236
|
+
|
|
237
|
+
style : BoxStyle, optional
|
|
238
|
+
Style for the table, by default ``"normal"``
|
|
239
|
+
"""
|
|
240
|
+
|
|
241
|
+
# Text length
|
|
242
|
+
if ncols is None:
|
|
243
|
+
try:
|
|
244
|
+
self.ncols = os.get_terminal_size().columns
|
|
245
|
+
except OSError:
|
|
246
|
+
self.ncols = 88
|
|
247
|
+
else:
|
|
248
|
+
self.ncols = max(5, ncols)
|
|
249
|
+
|
|
250
|
+
# Title & paragraph
|
|
251
|
+
self._title = ""
|
|
252
|
+
self._paragraphs: list[Sequence[str]] = []
|
|
253
|
+
|
|
254
|
+
# Style
|
|
255
|
+
self._table_char = get_box_drawing_character(style=style)
|
|
256
|
+
|
|
257
|
+
# Text wrapper
|
|
258
|
+
self._text_wrapper = TextWrapper(
|
|
259
|
+
width=self.ncols - 4,
|
|
260
|
+
initial_indent="",
|
|
261
|
+
subsequent_indent="",
|
|
262
|
+
tabsize=4,
|
|
263
|
+
break_long_words=True,
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
def add_title(self, title: str) -> None:
|
|
267
|
+
"""
|
|
268
|
+
Add title to Table
|
|
269
|
+
|
|
270
|
+
Parameters
|
|
271
|
+
----------
|
|
272
|
+
title : str
|
|
273
|
+
Title to add.
|
|
274
|
+
When ``len(title) > ncols``: title will not show
|
|
275
|
+
"""
|
|
276
|
+
max_padding_length = self.ncols - 2
|
|
277
|
+
if max_padding_length < (len(title) + 2) or len(title) < 1:
|
|
278
|
+
_title = ""
|
|
279
|
+
else:
|
|
280
|
+
_title = f" {title} "
|
|
281
|
+
|
|
282
|
+
line = (
|
|
283
|
+
f"{self._table_char.UPPER_LEFT_CORNER}"
|
|
284
|
+
f"{_title.center(max_padding_length, self._table_char.HORIZONTAL)}"
|
|
285
|
+
f"{self._table_char.UPPER_RIGHT_CORNER}"
|
|
286
|
+
)
|
|
287
|
+
self._title = line
|
|
288
|
+
|
|
289
|
+
def add_paragraph(self, paragraph: Sequence[str]) -> None:
|
|
290
|
+
"""
|
|
291
|
+
Add paragraph into Table
|
|
292
|
+
|
|
293
|
+
Parameters
|
|
294
|
+
----------
|
|
295
|
+
paragraph : Sequence[str]
|
|
296
|
+
An iterable of str
|
|
297
|
+
"""
|
|
298
|
+
if isinstance(paragraph, str):
|
|
299
|
+
self._paragraphs.append([paragraph])
|
|
300
|
+
else:
|
|
301
|
+
self._paragraphs.append(paragraph)
|
|
302
|
+
|
|
303
|
+
def _make_line(self, option: Literal[0, 1, 2]) -> str:
|
|
304
|
+
options = (
|
|
305
|
+
(self._table_char.UPPER_LEFT_CORNER, self._table_char.UPPER_RIGHT_CORNER),
|
|
306
|
+
(self._table_char.VERTICAL_RIGHT, self._table_char.VERTICAL_LEFT),
|
|
307
|
+
(self._table_char.LOWER_LEFT_CORNER, self._table_char.LOWER_RIGHT_CORNER),
|
|
308
|
+
)
|
|
309
|
+
max_line_length = self.ncols - 2
|
|
310
|
+
line = (
|
|
311
|
+
f"{options[option][0]}"
|
|
312
|
+
f"{''.ljust(max_line_length, self._table_char.HORIZONTAL)}"
|
|
313
|
+
f"{options[option][1]}"
|
|
314
|
+
)
|
|
315
|
+
return line
|
|
316
|
+
|
|
317
|
+
def _make_table(self) -> list[str] | None:
|
|
318
|
+
# Check if empty
|
|
319
|
+
if len(self._paragraphs) < 1:
|
|
320
|
+
return None
|
|
321
|
+
if len(self._paragraphs[0]) < 1:
|
|
322
|
+
return None
|
|
323
|
+
|
|
324
|
+
# Make table
|
|
325
|
+
max_content_length = self.ncols - 4
|
|
326
|
+
paragraph_length = len(self._paragraphs)
|
|
327
|
+
|
|
328
|
+
# Line prep
|
|
329
|
+
_first_line = self._make_line(0)
|
|
330
|
+
_sep_line = self._make_line(1)
|
|
331
|
+
_last_line = self._make_line(2)
|
|
332
|
+
|
|
333
|
+
# Table
|
|
334
|
+
table: list[str] = [_first_line] if self._title == "" else [self._title]
|
|
335
|
+
for i, paragraph in enumerate(self._paragraphs, start=1):
|
|
336
|
+
for line in paragraph:
|
|
337
|
+
splitted_line = self._text_wrapper.wrap(line) if len(line) > 0 else [""]
|
|
338
|
+
mod_lines: list[str] = [
|
|
339
|
+
f"{self._table_char.VERTICAL} "
|
|
340
|
+
f"{line.ljust(max_content_length, ' ')}"
|
|
341
|
+
f" {self._table_char.VERTICAL}"
|
|
342
|
+
for line in splitted_line
|
|
343
|
+
]
|
|
344
|
+
table.extend(mod_lines)
|
|
345
|
+
|
|
346
|
+
if i != paragraph_length:
|
|
347
|
+
table.append(_sep_line)
|
|
348
|
+
else:
|
|
349
|
+
table.append(_last_line)
|
|
350
|
+
return table
|
|
351
|
+
|
|
352
|
+
def make_table(self) -> str:
|
|
353
|
+
table = self._make_table()
|
|
354
|
+
if table is None:
|
|
355
|
+
return ""
|
|
356
|
+
return "\n".join(table)
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
# W.I.P
|
|
360
|
+
# ---------------------------------------------------------------------------
|
|
361
|
+
class _BoxDrawingCharacterFactory:
|
|
362
|
+
_TRANSLATE: dict[str, str] = {
|
|
363
|
+
"n": "normal",
|
|
364
|
+
"d": "dashed",
|
|
365
|
+
"b": "bold",
|
|
366
|
+
"r": "rounded",
|
|
367
|
+
"x": "double",
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
UPPER_LEFT_CORNER: list[tuple[str, str]] = [
|
|
371
|
+
("\u250c", "n,d"),
|
|
372
|
+
("\u256d", "r"),
|
|
373
|
+
("\u250f", "b"),
|
|
374
|
+
("\u2554", "x"),
|
|
375
|
+
]
|
|
376
|
+
UPPER_RIGHT_CORNER: list[tuple[str, str]] = [
|
|
377
|
+
("\u2510", "n,d"),
|
|
378
|
+
("\u256e", "r"),
|
|
379
|
+
("\u2513", "b"),
|
|
380
|
+
("\u2557", "x"),
|
|
381
|
+
]
|
|
382
|
+
HORIZONTAL: list[tuple[str, str]] = [
|
|
383
|
+
("\u2500", "n,r"),
|
|
384
|
+
("\u254c", "d"),
|
|
385
|
+
("\u2501", "b"),
|
|
386
|
+
("\u2550", "x"),
|
|
387
|
+
]
|
|
388
|
+
VERTICAL: list[tuple[str, str]] = [
|
|
389
|
+
("\u2502", "n,r"),
|
|
390
|
+
("\u254e", "d"),
|
|
391
|
+
("\u2503", "b"),
|
|
392
|
+
("\u2551", "x"),
|
|
393
|
+
]
|
|
394
|
+
LOWER_LEFT_CORNER: list[tuple[str, str]] = [
|
|
395
|
+
("\u2514", "n,d"),
|
|
396
|
+
("\u2570", "r"),
|
|
397
|
+
("\u2517", "b"),
|
|
398
|
+
("\u255a", "x"),
|
|
399
|
+
]
|
|
400
|
+
LOWER_RIGHT_CORNER: list[tuple[str, str]] = [
|
|
401
|
+
("\u2518", "n,d"),
|
|
402
|
+
("\u256f", "r"),
|
|
403
|
+
("\u251b", "b"),
|
|
404
|
+
("\u255d", "x"),
|
|
405
|
+
]
|
|
406
|
+
VERTICAL_RIGHT: list[tuple[str, str]] = [
|
|
407
|
+
("\u251c", "n,d,r"),
|
|
408
|
+
("\u2523", "b"),
|
|
409
|
+
("\u2560", "x"),
|
|
410
|
+
]
|
|
411
|
+
VERTICAL_LEFT: list[tuple[str, str]] = [
|
|
412
|
+
("\u2524", "n,d,r"),
|
|
413
|
+
("\u252b", "b"),
|
|
414
|
+
("\u2563", "x"),
|
|
415
|
+
]
|
|
416
|
+
CROSS: list[tuple[str, str]] = [
|
|
417
|
+
("\u253c", "n,d,r"),
|
|
418
|
+
("\u254b", "b"),
|
|
419
|
+
("\u256c", "x"),
|
|
420
|
+
]
|
|
421
|
+
HORIZONTAL_UP: list[tuple[str, str]] = [
|
|
422
|
+
("\u2534", "n,d,r"),
|
|
423
|
+
("\u253b", "b"),
|
|
424
|
+
("\u2569", "x"),
|
|
425
|
+
]
|
|
426
|
+
HORIZONTAL_DOWN: list[tuple[str, str]] = [
|
|
427
|
+
("\u252c", "n,d,r"),
|
|
428
|
+
("\u2533", "b"),
|
|
429
|
+
("\u2566", "x"),
|
|
430
|
+
]
|
|
431
|
+
|
|
432
|
+
_FIELDS: tuple[str, ...] = (
|
|
433
|
+
"UPPER_LEFT_CORNER",
|
|
434
|
+
"UPPER_RIGHT_CORNER",
|
|
435
|
+
"HORIZONTAL",
|
|
436
|
+
"VERTICAL",
|
|
437
|
+
"LOWER_LEFT_CORNER",
|
|
438
|
+
"LOWER_RIGHT_CORNER",
|
|
439
|
+
"VERTICAL_RIGHT",
|
|
440
|
+
"VERTICAL_LEFT",
|
|
441
|
+
"CROSS",
|
|
442
|
+
"HORIZONTAL_UP",
|
|
443
|
+
"HORIZONTAL_DOWN",
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
def __init__(self, style: str | None = None):
|
|
447
|
+
self.style = style
|
|
448
|
+
|
|
449
|
+
@classmethod
|
|
450
|
+
def _make_style(cls) -> dict[str, dict[str, str]]:
|
|
451
|
+
"""
|
|
452
|
+
Creates a style dictionary based on the class attributes.
|
|
453
|
+
|
|
454
|
+
Returns
|
|
455
|
+
-------
|
|
456
|
+
dict[str, dict[str, str]]
|
|
457
|
+
A dictionary mapping group names to style configurations.
|
|
458
|
+
"""
|
|
459
|
+
|
|
460
|
+
# Initialize an empty style dictionary
|
|
461
|
+
style: dict[str, dict[str, str]] = {}
|
|
462
|
+
|
|
463
|
+
# Create a dictionary mapping field names to themselves
|
|
464
|
+
field_map = {field: "" for field in cls._FIELDS}
|
|
465
|
+
|
|
466
|
+
# Initialize style entries for each translation key
|
|
467
|
+
for x in cls._TRANSLATE.keys():
|
|
468
|
+
style[x] = field_map
|
|
469
|
+
|
|
470
|
+
# Extract character data from class fields
|
|
471
|
+
char_data: list[tuple[str, list[tuple[str, str]]]] = [
|
|
472
|
+
(field, getattr(cls, field)) for field in cls._FIELDS
|
|
473
|
+
]
|
|
474
|
+
|
|
475
|
+
# Populate the style dictionary with character mappings
|
|
476
|
+
for name, chars in char_data:
|
|
477
|
+
for char, groups in chars:
|
|
478
|
+
for group in map(str.strip, groups.split(",")):
|
|
479
|
+
style[group][name] = char
|
|
480
|
+
|
|
481
|
+
return style
|
absfuyu/util/zipped.py
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Absfuyu: Zipped
|
|
3
3
|
---------------
|
|
4
|
-
Zipping stuff
|
|
4
|
+
Zipping stuff
|
|
5
|
+
(deprecated, use absfuyu.util.path.Directory)
|
|
5
6
|
|
|
6
|
-
Version: 1.1
|
|
7
|
-
Date updated:
|
|
7
|
+
Version: 6.1.1
|
|
8
|
+
Date updated: 30/12/2025 (dd/mm/yyyy)
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
11
|
# Module level
|
|
11
12
|
# ---------------------------------------------------------------------------
|
|
12
|
-
__all__ = [
|
|
13
|
-
"Zipper",
|
|
14
|
-
]
|
|
13
|
+
__all__ = ["Zipper"]
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
# Library
|
|
@@ -20,11 +19,13 @@ import shutil
|
|
|
20
19
|
import zipfile
|
|
21
20
|
from pathlib import Path
|
|
22
21
|
|
|
23
|
-
from absfuyu.core import BaseClass, versionadded
|
|
22
|
+
from absfuyu.core import BaseClass, deprecated, versionadded
|
|
24
23
|
from absfuyu.logger import logger
|
|
25
24
|
|
|
26
25
|
|
|
26
|
+
# Class
|
|
27
27
|
# ---------------------------------------------------------------------------
|
|
28
|
+
@deprecated("5.1.0", reason="Use ``absfuyu.util.path.Directory`` instead")
|
|
28
29
|
class Zipper(BaseClass):
|
|
29
30
|
"""Zip file or folder"""
|
|
30
31
|
|