absfuyu 5.12.1__py3-none-any.whl → 5.13.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 +1 -1
- absfuyu/cli/__init__.py +1 -1
- absfuyu/cli/color.py +1 -1
- absfuyu/cli/config_group.py +1 -1
- absfuyu/cli/do_group.py +1 -1
- absfuyu/cli/game_group.py +1 -1
- absfuyu/cli/tool_group.py +18 -4
- absfuyu/config/__init__.py +1 -1
- absfuyu/core/__init__.py +1 -1
- absfuyu/core/baseclass.py +1 -1
- absfuyu/core/baseclass2.py +1 -1
- absfuyu/core/decorator.py +1 -1
- absfuyu/core/docstring.py +1 -1
- absfuyu/core/dummy_cli.py +1 -1
- absfuyu/core/dummy_func.py +1 -1
- absfuyu/dxt/__init__.py +1 -1
- absfuyu/dxt/base_type.py +93 -0
- absfuyu/dxt/dictext.py +8 -6
- absfuyu/dxt/dxt_support.py +1 -1
- absfuyu/dxt/intext.py +76 -3
- absfuyu/dxt/listext.py +1 -1
- absfuyu/dxt/strext.py +1 -1
- absfuyu/extra/__init__.py +1 -1
- absfuyu/extra/beautiful.py +1 -1
- absfuyu/extra/da/__init__.py +1 -1
- absfuyu/extra/da/dadf.py +1 -1
- absfuyu/extra/da/dadf_base.py +1 -1
- absfuyu/extra/da/df_func.py +1 -1
- absfuyu/extra/da/mplt.py +1 -1
- absfuyu/extra/data_analysis.py +1 -1
- absfuyu/extra/pdf.py +1 -1
- absfuyu/extra/picture.py +386 -0
- absfuyu/extra/rclone.py +1 -1
- absfuyu/extra/xml.py +1 -1
- absfuyu/fun/__init__.py +1 -1
- absfuyu/fun/rubik.py +1 -1
- absfuyu/fun/tarot.py +1 -1
- absfuyu/game/__init__.py +1 -1
- absfuyu/game/game_stat.py +1 -1
- absfuyu/game/schulte.py +1 -1
- absfuyu/game/sudoku.py +1 -1
- absfuyu/game/tictactoe.py +1 -1
- absfuyu/game/wordle.py +1 -1
- absfuyu/general/__init__.py +1 -1
- absfuyu/general/content.py +1 -1
- absfuyu/general/human.py +1 -1
- absfuyu/general/shape.py +1 -1
- absfuyu/general/tax.py +1 -1
- absfuyu/logger.py +1 -1
- absfuyu/pkg_data/__init__.py +1 -1
- absfuyu/pkg_data/deprecated.py +1 -1
- absfuyu/pkg_data/logo.py +1 -1
- absfuyu/sort.py +1 -1
- absfuyu/tools/__init__.py +1 -1
- absfuyu/tools/checksum.py +1 -1
- absfuyu/tools/converter.py +1 -1
- absfuyu/tools/generator.py +24 -7
- absfuyu/tools/inspector.py +1 -1
- absfuyu/tools/keygen.py +1 -1
- absfuyu/tools/obfuscator.py +1 -1
- absfuyu/tools/passwordlib.py +1 -1
- absfuyu/tools/shutdownizer.py +1 -1
- absfuyu/tools/sw.py +1 -1
- absfuyu/tools/web.py +1 -1
- absfuyu/typings.py +1 -1
- absfuyu/util/__init__.py +1 -1
- absfuyu/util/api.py +1 -1
- absfuyu/util/cli.py +1 -1
- absfuyu/util/gui.py +1 -1
- absfuyu/util/json_method.py +1 -1
- absfuyu/util/lunar.py +1 -1
- absfuyu/util/path.py +1 -1
- absfuyu/util/performance.py +1 -1
- absfuyu/util/shorten_number.py +1 -1
- absfuyu/util/text_table.py +1 -1
- absfuyu/util/zipped.py +1 -1
- absfuyu/version.py +1 -1
- {absfuyu-5.12.1.dist-info → absfuyu-5.13.0.dist-info}/METADATA +10 -1
- absfuyu-5.13.0.dist-info/RECORD +88 -0
- absfuyu-5.12.1.dist-info/RECORD +0 -86
- {absfuyu-5.12.1.dist-info → absfuyu-5.13.0.dist-info}/WHEEL +0 -0
- {absfuyu-5.12.1.dist-info → absfuyu-5.13.0.dist-info}/entry_points.txt +0 -0
- {absfuyu-5.12.1.dist-info → absfuyu-5.13.0.dist-info}/licenses/LICENSE +0 -0
absfuyu/__init__.py
CHANGED
absfuyu/__main__.py
CHANGED
absfuyu/cli/__init__.py
CHANGED
absfuyu/cli/color.py
CHANGED
absfuyu/cli/config_group.py
CHANGED
absfuyu/cli/do_group.py
CHANGED
absfuyu/cli/game_group.py
CHANGED
absfuyu/cli/tool_group.py
CHANGED
|
@@ -3,8 +3,8 @@ ABSFUYU CLI
|
|
|
3
3
|
-----------
|
|
4
4
|
Tool
|
|
5
5
|
|
|
6
|
-
Version: 5.
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 5.13.0
|
|
7
|
+
Date updated: 02/11/2025 (dd/mm/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
# Module Package
|
|
@@ -14,6 +14,7 @@ __all__ = ["tool_group"]
|
|
|
14
14
|
|
|
15
15
|
# Library
|
|
16
16
|
# ---------------------------------------------------------------------------
|
|
17
|
+
from pathlib import Path
|
|
17
18
|
from typing import Literal
|
|
18
19
|
|
|
19
20
|
import click
|
|
@@ -24,7 +25,7 @@ from absfuyu.tools.converter import Base64EncodeDecode, Text2Chemistry
|
|
|
24
25
|
|
|
25
26
|
# CLI
|
|
26
27
|
# ---------------------------------------------------------------------------
|
|
27
|
-
@click.command(name="
|
|
28
|
+
@click.command(name="cs")
|
|
28
29
|
@click.argument("file_path", type=str)
|
|
29
30
|
@click.option(
|
|
30
31
|
"--hashmode",
|
|
@@ -80,6 +81,18 @@ def file_checksum(
|
|
|
80
81
|
click.echo(res == hash_to_compare)
|
|
81
82
|
|
|
82
83
|
|
|
84
|
+
@click.command(name="cimg")
|
|
85
|
+
@click.argument("file_path", type=str)
|
|
86
|
+
@click.argument("to_format", type=str)
|
|
87
|
+
def convert_img(file_path: str, to_format: str) -> None:
|
|
88
|
+
"""Convert img in directory"""
|
|
89
|
+
from absfuyu.extra.picture import ImgConverter
|
|
90
|
+
|
|
91
|
+
engine = ImgConverter(Path(file_path).resolve())
|
|
92
|
+
engine.img_convert(to_format)
|
|
93
|
+
click.echo("Done")
|
|
94
|
+
|
|
95
|
+
|
|
83
96
|
@click.command(name="t2c")
|
|
84
97
|
@click.argument("text", type=str)
|
|
85
98
|
def text2chem(text: str) -> None:
|
|
@@ -121,7 +134,7 @@ def base64convert_img(img_path: str, data_tag: bool) -> None:
|
|
|
121
134
|
|
|
122
135
|
|
|
123
136
|
@click.group(name="b64")
|
|
124
|
-
def base64_group():
|
|
137
|
+
def base64_group() -> None:
|
|
125
138
|
"""Base64 encode decode"""
|
|
126
139
|
pass
|
|
127
140
|
|
|
@@ -138,5 +151,6 @@ def tool_group() -> None:
|
|
|
138
151
|
|
|
139
152
|
|
|
140
153
|
tool_group.add_command(file_checksum)
|
|
154
|
+
tool_group.add_command(convert_img)
|
|
141
155
|
tool_group.add_command(base64_group)
|
|
142
156
|
tool_group.add_command(text2chem)
|
absfuyu/config/__init__.py
CHANGED
absfuyu/core/__init__.py
CHANGED
absfuyu/core/baseclass.py
CHANGED
absfuyu/core/baseclass2.py
CHANGED
absfuyu/core/decorator.py
CHANGED
absfuyu/core/docstring.py
CHANGED
absfuyu/core/dummy_cli.py
CHANGED
absfuyu/core/dummy_func.py
CHANGED
absfuyu/dxt/__init__.py
CHANGED
absfuyu/dxt/base_type.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Absfuyu: Data Extension
|
|
3
|
+
-----------------------
|
|
4
|
+
Base type expansion
|
|
5
|
+
|
|
6
|
+
Version: 5.13.0
|
|
7
|
+
Date updated: 28/10/2025 (dd/mm/yyyy)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
# Module Package
|
|
13
|
+
# ---------------------------------------------------------------------------
|
|
14
|
+
__all__ = []
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# Library
|
|
18
|
+
# ---------------------------------------------------------------------------
|
|
19
|
+
from abc import ABC
|
|
20
|
+
from typing import Generic, Self, TypeVar
|
|
21
|
+
|
|
22
|
+
# Class
|
|
23
|
+
# ---------------------------------------------------------------------------
|
|
24
|
+
T = TypeVar("T")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class BaseType(Generic[T], ABC):
|
|
28
|
+
"""
|
|
29
|
+
A universal base class for creating custom immutable type wrappers.
|
|
30
|
+
|
|
31
|
+
Features:
|
|
32
|
+
----------
|
|
33
|
+
- Works with any immutable type (int, str, float, etc.)
|
|
34
|
+
- Provides validation hook via `_validate`
|
|
35
|
+
- Automatically infers the base type from generic argument
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
--------
|
|
40
|
+
>>> class NonNegativeInt(BaseType[int], int):
|
|
41
|
+
>>> @classmethod
|
|
42
|
+
>>> def _validate(cls, value: int) -> None:
|
|
43
|
+
>>> if value < 0:
|
|
44
|
+
>>> raise ValueError("Value must be non-negative")
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
# Automatically infer `_base_type` when subclassed
|
|
48
|
+
def __init_subclass__(cls, *args, **kwargs) -> None:
|
|
49
|
+
super().__init_subclass__(*args, **kwargs)
|
|
50
|
+
|
|
51
|
+
# print(getattr(cls, "__orig_bases__", []))
|
|
52
|
+
for base in getattr(cls, "__orig_bases__", []):
|
|
53
|
+
if hasattr(base, "__args__") and base.__args__:
|
|
54
|
+
cls._base_type: type[T] = base.__args__[0]
|
|
55
|
+
break
|
|
56
|
+
else:
|
|
57
|
+
raise TypeError(f"{cls.__name__} must specify a generic base type, e.g. BaseType[int]")
|
|
58
|
+
|
|
59
|
+
def __new__(cls, value: T) -> Self:
|
|
60
|
+
base_type = cls._base_type
|
|
61
|
+
if not isinstance(value, base_type):
|
|
62
|
+
raise TypeError(f"{cls.__name__} must be initialized with {base_type.__name__}, got {type(value).__name__}")
|
|
63
|
+
cls._validate(value)
|
|
64
|
+
return base_type.__new__(cls, value) # type: ignore
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def _validate(cls, value: T) -> None:
|
|
68
|
+
"""Override this in subclasses to add custom validation."""
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
def __repr__(self) -> str:
|
|
72
|
+
# base_name = self._base_type.__name__
|
|
73
|
+
# return f"{self.__class__.__name__}({base_name}={self._base_type(self)!r})" # type: ignore
|
|
74
|
+
return f"{self.__class__.__name__}({self._base_type(self)!r})" # type: ignore
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class IntBase(BaseType[int], int):
|
|
78
|
+
"""
|
|
79
|
+
A base class for creating custom integer-like types.
|
|
80
|
+
Provides a hook for validation and extension.
|
|
81
|
+
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
value : int
|
|
85
|
+
Int value
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
Usage:
|
|
89
|
+
------
|
|
90
|
+
Use ``_validate(cls, value: int) -> None:`` classmethod to create custom validator
|
|
91
|
+
"""
|
|
92
|
+
|
|
93
|
+
pass
|
absfuyu/dxt/dictext.py
CHANGED
|
@@ -3,10 +3,12 @@ Absfuyu: Data Extension
|
|
|
3
3
|
-----------------------
|
|
4
4
|
dict extension
|
|
5
5
|
|
|
6
|
-
Version: 5.
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 5.13.0
|
|
7
|
+
Date updated: 02/11/2025 (dd/mm/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
10
12
|
# Module Package
|
|
11
13
|
# ---------------------------------------------------------------------------
|
|
12
14
|
__all__ = ["DictExt", "DictAnalyzeResult"]
|
|
@@ -259,7 +261,7 @@ class DictExt(GetClassMembersMixin, dict[KT, VT]):
|
|
|
259
261
|
raise ValueError(err_msg) # noqa: B904
|
|
260
262
|
|
|
261
263
|
# Swap
|
|
262
|
-
def swap_items(self) ->
|
|
264
|
+
def swap_items(self) -> DictExt[VT, KT]:
|
|
263
265
|
"""
|
|
264
266
|
Swap ``dict.keys()`` with ``dict.values()``
|
|
265
267
|
|
|
@@ -282,12 +284,12 @@ class DictExt(GetClassMembersMixin, dict[KT, VT]):
|
|
|
282
284
|
|
|
283
285
|
# Apply
|
|
284
286
|
@overload
|
|
285
|
-
def apply(self, func: Callable[[VT], R]) ->
|
|
287
|
+
def apply(self, func: Callable[[VT], R]) -> DictExt[KT, R]: ...
|
|
286
288
|
|
|
287
289
|
@overload
|
|
288
|
-
def apply(self, func: Callable[[KT], R], apply_to_value: Literal[False] = ...) ->
|
|
290
|
+
def apply(self, func: Callable[[KT], R], apply_to_value: Literal[False] = ...) -> DictExt[R, VT]: ...
|
|
289
291
|
|
|
290
|
-
def apply(self, func: Callable[[KT | VT], R], apply_to_value: bool = True): # type: ignore
|
|
292
|
+
def apply(self, func: Callable[[KT | VT], R], apply_to_value: bool = True) -> DictExt[KT | R, VT | R]: # type: ignore
|
|
291
293
|
"""
|
|
292
294
|
Apply function to ``DictExt.keys()`` or ``DictExt.values()``
|
|
293
295
|
|
absfuyu/dxt/dxt_support.py
CHANGED
absfuyu/dxt/intext.py
CHANGED
|
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
|
|
|
3
3
|
-----------------------
|
|
4
4
|
int extension
|
|
5
5
|
|
|
6
|
-
Version: 5.
|
|
7
|
-
Date updated:
|
|
6
|
+
Version: 5.13.0
|
|
7
|
+
Date updated: 28/10/2025 (dd/mm/yyyy)
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
10
|
# Module Package
|
|
@@ -15,9 +15,15 @@ __all__ = ["IntExt", "Pow"]
|
|
|
15
15
|
# Library
|
|
16
16
|
# ---------------------------------------------------------------------------
|
|
17
17
|
import math
|
|
18
|
+
from abc import ABC
|
|
18
19
|
from collections import Counter
|
|
19
20
|
from typing import Any, Literal, Self, overload
|
|
20
21
|
|
|
22
|
+
try:
|
|
23
|
+
from typing import override # type: ignore
|
|
24
|
+
except ImportError:
|
|
25
|
+
from absfuyu.core.decorator import dummy_decorator as override
|
|
26
|
+
|
|
21
27
|
from absfuyu.core.baseclass import GetClassMembersMixin
|
|
22
28
|
from absfuyu.core.docstring import deprecated, versionadded, versionchanged
|
|
23
29
|
from absfuyu.dxt.dxt_support import DictBoolTrue
|
|
@@ -493,7 +499,7 @@ class IntExt(GetClassMembersMixin, int):
|
|
|
493
499
|
return divi_list
|
|
494
500
|
|
|
495
501
|
@overload
|
|
496
|
-
def prime_factor(self) -> list[Pow]: ...
|
|
502
|
+
def prime_factor(self) -> list[Pow]: ... # type: ignore
|
|
497
503
|
|
|
498
504
|
@overload
|
|
499
505
|
def prime_factor(self, short_form: Literal[False] = ...) -> list[int]: ...
|
|
@@ -633,3 +639,70 @@ class IntExt(GetClassMembersMixin, int):
|
|
|
633
639
|
|
|
634
640
|
quotient, remainder = divmod(self, p)
|
|
635
641
|
return [quotient + (i >= (p - remainder)) for i in range(p)]
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
# Class
|
|
645
|
+
# ---------------------------------------------------------------------------
|
|
646
|
+
class IntBase(int, ABC):
|
|
647
|
+
"""
|
|
648
|
+
A base class for creating custom integer-like types.
|
|
649
|
+
Provides a hook for validation and extension.
|
|
650
|
+
|
|
651
|
+
Usage:
|
|
652
|
+
------
|
|
653
|
+
Use ``_validate(cls, value: int) -> None:`` classmethod to create custom validator
|
|
654
|
+
"""
|
|
655
|
+
|
|
656
|
+
def __new__(cls, value: int = 0) -> Self:
|
|
657
|
+
# Ensure the value is an integer
|
|
658
|
+
if not isinstance(value, int):
|
|
659
|
+
raise TypeError(f"{cls.__name__} must be initialized with an int, got {type(value).__name__}")
|
|
660
|
+
# Optional validation hook
|
|
661
|
+
cls._validate(value)
|
|
662
|
+
return int.__new__(cls, value)
|
|
663
|
+
|
|
664
|
+
@classmethod
|
|
665
|
+
def _validate(cls, value: int) -> None:
|
|
666
|
+
"""Override in subclasses to add custom validation."""
|
|
667
|
+
pass
|
|
668
|
+
|
|
669
|
+
def __repr__(self) -> str:
|
|
670
|
+
return f"{self.__class__.__name__}({int(self)})"
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
class PositiveInt(IntBase):
|
|
674
|
+
"""Only allows positive int"""
|
|
675
|
+
|
|
676
|
+
@classmethod
|
|
677
|
+
@override
|
|
678
|
+
def _validate(cls, value: int) -> None:
|
|
679
|
+
if value < 0:
|
|
680
|
+
raise ValueError(f"{cls.__name__} must be non-negative")
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
class NegativeInt(IntBase):
|
|
684
|
+
"""Only allows negative int"""
|
|
685
|
+
|
|
686
|
+
@classmethod
|
|
687
|
+
@override
|
|
688
|
+
def _validate(cls, value: int) -> None:
|
|
689
|
+
if value >= 0:
|
|
690
|
+
raise ValueError(f"{cls.__name__} must be non-positive")
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
class IntWithNote(IntBase):
|
|
694
|
+
"""Int with additional note"""
|
|
695
|
+
|
|
696
|
+
def __new__(cls, value: int = 0) -> Self:
|
|
697
|
+
ins = super().__new__(cls, value)
|
|
698
|
+
ins.note = ""
|
|
699
|
+
return ins
|
|
700
|
+
|
|
701
|
+
def __repr__(self) -> str:
|
|
702
|
+
if self.note == "":
|
|
703
|
+
return f"{int(self)}"
|
|
704
|
+
# return super().__repr__()
|
|
705
|
+
return f"{self.__class__.__name__}({int(self)}, note={repr(self.note)})"
|
|
706
|
+
|
|
707
|
+
def add_note(self, note: str) -> None:
|
|
708
|
+
self.note = note
|
absfuyu/dxt/listext.py
CHANGED
absfuyu/dxt/strext.py
CHANGED
absfuyu/extra/__init__.py
CHANGED
absfuyu/extra/beautiful.py
CHANGED
absfuyu/extra/da/__init__.py
CHANGED
absfuyu/extra/da/dadf.py
CHANGED
absfuyu/extra/da/dadf_base.py
CHANGED
absfuyu/extra/da/df_func.py
CHANGED
absfuyu/extra/da/mplt.py
CHANGED
absfuyu/extra/data_analysis.py
CHANGED