absfuyu 4.1.1__py3-none-any.whl → 5.0.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.

Files changed (76) hide show
  1. absfuyu/__init__.py +4 -4
  2. absfuyu/__main__.py +13 -1
  3. absfuyu/cli/__init__.py +4 -2
  4. absfuyu/cli/color.py +7 -0
  5. absfuyu/cli/do_group.py +9 -91
  6. absfuyu/cli/tool_group.py +136 -0
  7. absfuyu/config/__init__.py +17 -34
  8. absfuyu/core/__init__.py +49 -0
  9. absfuyu/core/baseclass.py +299 -0
  10. absfuyu/core/baseclass2.py +165 -0
  11. absfuyu/core/decorator.py +67 -0
  12. absfuyu/core/docstring.py +163 -0
  13. absfuyu/core/dummy_cli.py +67 -0
  14. absfuyu/core/dummy_func.py +47 -0
  15. absfuyu/dxt/__init__.py +42 -0
  16. absfuyu/dxt/dictext.py +201 -0
  17. absfuyu/dxt/dxt_support.py +79 -0
  18. absfuyu/dxt/intext.py +586 -0
  19. absfuyu/dxt/listext.py +508 -0
  20. absfuyu/dxt/strext.py +530 -0
  21. absfuyu/{extensions → extra}/__init__.py +3 -2
  22. absfuyu/extra/beautiful.py +251 -0
  23. absfuyu/{extensions/extra → extra}/data_analysis.py +51 -82
  24. absfuyu/fun/__init__.py +110 -135
  25. absfuyu/fun/tarot.py +9 -17
  26. absfuyu/game/__init__.py +6 -0
  27. absfuyu/game/game_stat.py +6 -0
  28. absfuyu/game/sudoku.py +7 -1
  29. absfuyu/game/tictactoe.py +12 -5
  30. absfuyu/game/wordle.py +14 -8
  31. absfuyu/general/__init__.py +6 -79
  32. absfuyu/general/content.py +22 -36
  33. absfuyu/general/generator.py +17 -42
  34. absfuyu/general/human.py +108 -228
  35. absfuyu/general/shape.py +1334 -0
  36. absfuyu/logger.py +8 -13
  37. absfuyu/pkg_data/__init__.py +137 -99
  38. absfuyu/pkg_data/deprecated.py +133 -0
  39. absfuyu/pkg_data/passwordlib_lzma.pkl +0 -0
  40. absfuyu/sort.py +6 -130
  41. absfuyu/tools/__init__.py +2 -2
  42. absfuyu/tools/checksum.py +44 -22
  43. absfuyu/tools/converter.py +82 -50
  44. absfuyu/tools/keygen.py +25 -30
  45. absfuyu/tools/obfuscator.py +246 -112
  46. absfuyu/tools/passwordlib.py +330 -0
  47. absfuyu/tools/shutdownizer.py +287 -0
  48. absfuyu/tools/web.py +2 -9
  49. absfuyu/util/__init__.py +15 -15
  50. absfuyu/util/api.py +10 -15
  51. absfuyu/util/json_method.py +7 -24
  52. absfuyu/util/lunar.py +3 -9
  53. absfuyu/util/path.py +22 -27
  54. absfuyu/util/performance.py +43 -67
  55. absfuyu/util/shorten_number.py +65 -14
  56. absfuyu/util/zipped.py +9 -15
  57. absfuyu-5.0.0.dist-info/METADATA +143 -0
  58. absfuyu-5.0.0.dist-info/RECORD +68 -0
  59. absfuyu/core.py +0 -57
  60. absfuyu/everything.py +0 -32
  61. absfuyu/extensions/beautiful.py +0 -188
  62. absfuyu/extensions/dev/__init__.py +0 -244
  63. absfuyu/extensions/dev/password_hash.py +0 -80
  64. absfuyu/extensions/dev/passwordlib.py +0 -258
  65. absfuyu/extensions/dev/project_starter.py +0 -60
  66. absfuyu/extensions/dev/shutdownizer.py +0 -156
  67. absfuyu/extensions/extra/__init__.py +0 -24
  68. absfuyu/fun/WGS.py +0 -134
  69. absfuyu/general/data_extension.py +0 -1796
  70. absfuyu/tools/stats.py +0 -226
  71. absfuyu/util/pkl.py +0 -67
  72. absfuyu-4.1.1.dist-info/METADATA +0 -121
  73. absfuyu-4.1.1.dist-info/RECORD +0 -61
  74. {absfuyu-4.1.1.dist-info → absfuyu-5.0.0.dist-info}/WHEEL +0 -0
  75. {absfuyu-4.1.1.dist-info → absfuyu-5.0.0.dist-info}/entry_points.txt +0 -0
  76. {absfuyu-4.1.1.dist-info → absfuyu-5.0.0.dist-info}/licenses/LICENSE +0 -0
absfuyu/__init__.py CHANGED
@@ -15,19 +15,19 @@ Normal import:
15
15
  >>> import absfuyu
16
16
  >>> help(absfuyu)
17
17
 
18
- Using in cmd (`absfuyu[cli]` required):
18
+ Using in cmd:
19
19
  ``$ fuyu --help``
20
20
  """
21
21
 
22
22
  __title__ = "absfuyu"
23
23
  __author__ = "AbsoluteWinter"
24
24
  __license__ = "MIT License"
25
- __version__ = "4.1.1"
25
+ __version__ = "5.0.0"
26
26
  __all__ = [
27
27
  "core",
28
28
  "config",
29
- "everything",
30
- "extensions",
29
+ "dxt",
30
+ "extra",
31
31
  "logger",
32
32
  "fun",
33
33
  "game",
absfuyu/__main__.py CHANGED
@@ -2,14 +2,26 @@
2
2
  ABSFUYU
3
3
  -------
4
4
  COMMAND LINE INTERFACE
5
+
6
+ Version: 5.0.0
7
+ Date updated: 18/02/2025 (dd/mm/yyyy)
5
8
  """
6
9
 
7
- from absfuyu.cli import cli
10
+ # Library
11
+ # ---------------------------------------------------------------------------
12
+ try:
13
+ from absfuyu.cli import cli
14
+ except ModuleNotFoundError: # Check for `click`, `colorama`
15
+ from absfuyu.core.dummy_cli import cli
8
16
 
9
17
 
18
+ # Function
19
+ # ---------------------------------------------------------------------------
10
20
  def main() -> None:
11
21
  cli()
12
22
 
13
23
 
24
+ # Run
25
+ # ---------------------------------------------------------------------------
14
26
  if __name__ == "__main__":
15
27
  main()
absfuyu/cli/__init__.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU
3
3
  -------
4
4
  COMMAND LINE INTERFACE
5
5
 
6
- Version: 1.0.0
7
- Date updated: 14/04/2024 (dd/mm/yyyy)
6
+ Version: 1.1.0
7
+ Date updated: 09/02/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  __all__ = ["cli"]
@@ -19,6 +19,7 @@ from absfuyu.cli.color import COLOR
19
19
  from absfuyu.cli.config_group import config_group
20
20
  from absfuyu.cli.do_group import do_group
21
21
  from absfuyu.cli.game_group import game_group
22
+ from absfuyu.cli.tool_group import tool_group
22
23
 
23
24
  # Color stuff
24
25
  colorama.init(autoreset=True)
@@ -48,4 +49,5 @@ def cli() -> None:
48
49
  cli.add_command(config_group)
49
50
  cli.add_command(do_group)
50
51
  cli.add_command(game_group)
52
+ cli.add_command(tool_group)
51
53
  cli.add_command(version)
absfuyu/cli/color.py CHANGED
@@ -7,10 +7,17 @@ Version: 1.0.0
7
7
  Date updated: 14/04/2024 (dd/mm/yyyy)
8
8
  """
9
9
 
10
+ # Module Package
11
+ # ---------------------------------------------------------------------------
10
12
  __all__ = ["COLOR"]
11
13
 
14
+
15
+ # Library
16
+ # ---------------------------------------------------------------------------
12
17
  import colorama
13
18
 
19
+ # Color
20
+ # ---------------------------------------------------------------------------
14
21
  COLOR = {
15
22
  "green": colorama.Fore.LIGHTGREEN_EX,
16
23
  "GREEN": colorama.Fore.GREEN,
absfuyu/cli/do_group.py CHANGED
@@ -3,22 +3,20 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Do
5
5
 
6
- Version: 1.3.1
7
- Date updated: 01/02/2025 (dd/mm/yyyy)
6
+ Version: 1.4.0
7
+ Date updated: 07/02/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  __all__ = ["do_group"]
11
11
 
12
12
  import subprocess
13
- from typing import Literal
14
13
 
15
14
  import click
16
15
 
17
16
  from absfuyu import __title__
18
17
  from absfuyu.cli.color import COLOR
19
18
  from absfuyu.core import __package_feature__
20
- from absfuyu.general.human import Human2
21
- from absfuyu.tools.checksum import Checksum
19
+ from absfuyu.tools.shutdownizer import ShutDownizer
22
20
  from absfuyu.util.zipped import Zipper
23
21
  from absfuyu.version import PkgVersion
24
22
 
@@ -61,33 +59,6 @@ def install(pkg: str) -> None:
61
59
  click.echo(f"{COLOR['green']}absfuyu[{pkg}] installed")
62
60
 
63
61
 
64
- @click.command()
65
- def advice() -> None:
66
- """Give some recommendation when bored"""
67
- from absfuyu.fun import im_bored
68
-
69
- click.echo(f"{COLOR['green']}{im_bored()}")
70
-
71
-
72
- @click.command(name="fs")
73
- @click.argument("date", type=str)
74
- @click.argument("number_string", type=str)
75
- def fs(date: str, number_string: str) -> None:
76
- """Feng-shui W.I.P"""
77
-
78
- instance = Human2(date)
79
- print(instance.fs(number_string))
80
-
81
-
82
- @click.command(name="info")
83
- @click.argument("date", type=str)
84
- def info(date: str) -> None:
85
- """Day info"""
86
-
87
- instance = Human2(date)
88
- print(instance.info())
89
-
90
-
91
62
  @click.command(name="unzip")
92
63
  @click.argument("dir", type=str)
93
64
  def unzip_files_in_dir(dir: str) -> None:
@@ -98,61 +69,11 @@ def unzip_files_in_dir(dir: str) -> None:
98
69
  print("Done")
99
70
 
100
71
 
101
- @click.command(name="checksum")
102
- @click.argument("file_path", type=str)
103
- @click.option(
104
- "--hashmode",
105
- "-m",
106
- "hash_mode",
107
- type=click.Choice(["md5", "sha1", "sha256", "sha512"]),
108
- default="sha256",
109
- show_default=True,
110
- help="Hash mode",
111
- )
112
- @click.option(
113
- "--save-result",
114
- "-s",
115
- "save_result",
116
- type=bool,
117
- default=False,
118
- is_flag=True,
119
- show_default=True,
120
- help="Save checksum result to file",
121
- )
122
- @click.option(
123
- "--recursive",
124
- "-r",
125
- "recursive_mode",
126
- type=bool,
127
- default=False,
128
- is_flag=True,
129
- show_default=True,
130
- help="Do checksum for every file in the folder (including child folder)",
131
- )
132
- @click.option(
133
- "--compare",
134
- "-c",
135
- "hash_to_compare",
136
- type=str,
137
- default=None,
138
- show_default=True,
139
- help="Hash to compare",
140
- )
141
- def file_checksum(
142
- file_path: str,
143
- hash_mode: str | Literal["md5", "sha1", "sha256", "sha512"],
144
- save_result: bool,
145
- recursive_mode: bool,
146
- hash_to_compare: str,
147
- ) -> None:
148
- """Checksum for file"""
149
- # print(hash_mode, save_result, recursive_mode)
150
- instance = Checksum(file_path, hash_mode=hash_mode, save_result_to_file=save_result)
151
- res = instance.checksum(recursive=recursive_mode)
152
- if hash_to_compare:
153
- print(res == hash_to_compare)
154
- else:
155
- print(res)
72
+ @click.command(name="shutdown")
73
+ def os_shutdown() -> None:
74
+ """Shutdown"""
75
+ engine = ShutDownizer()
76
+ engine.shutdown()
156
77
 
157
78
 
158
79
  @click.group(name="do")
@@ -163,8 +84,5 @@ def do_group() -> None:
163
84
 
164
85
  do_group.add_command(update)
165
86
  do_group.add_command(install)
166
- do_group.add_command(advice)
167
- do_group.add_command(fs)
168
- do_group.add_command(info)
169
87
  do_group.add_command(unzip_files_in_dir)
170
- do_group.add_command(file_checksum)
88
+ do_group.add_command(os_shutdown)
@@ -0,0 +1,136 @@
1
+ """
2
+ ABSFUYU CLI
3
+ -----------
4
+ Tool
5
+
6
+ Version: 1.0.0
7
+ Date updated: 10/02/2025 (dd/mm/yyyy)
8
+ """
9
+
10
+ __all__ = ["tool_group"]
11
+
12
+ from typing import Literal
13
+
14
+ import click
15
+
16
+ from absfuyu.tools.checksum import Checksum
17
+ from absfuyu.tools.converter import Base64EncodeDecode, Text2Chemistry
18
+
19
+
20
+ @click.command(name="checksum")
21
+ @click.argument("file_path", type=str)
22
+ @click.option(
23
+ "--hashmode",
24
+ "-m",
25
+ "hash_mode",
26
+ type=click.Choice(["md5", "sha1", "sha256", "sha512"]),
27
+ default="sha256",
28
+ show_default=True,
29
+ help="Hash mode",
30
+ )
31
+ @click.option(
32
+ "--save-result",
33
+ "-s",
34
+ "save_result",
35
+ type=bool,
36
+ default=False,
37
+ is_flag=True,
38
+ show_default=True,
39
+ help="Save checksum result to file",
40
+ )
41
+ @click.option(
42
+ "--recursive",
43
+ "-r",
44
+ "recursive_mode",
45
+ type=bool,
46
+ default=False,
47
+ is_flag=True,
48
+ show_default=True,
49
+ help="Do checksum for every file in the folder (including child folder)",
50
+ )
51
+ @click.option(
52
+ "--compare",
53
+ "-c",
54
+ "hash_to_compare",
55
+ type=str,
56
+ default=None,
57
+ show_default=True,
58
+ help="Hash to compare",
59
+ )
60
+ def file_checksum(
61
+ file_path: str,
62
+ hash_mode: Literal["md5", "sha1", "sha256", "sha512"],
63
+ save_result: bool,
64
+ recursive_mode: bool,
65
+ hash_to_compare: str | None,
66
+ ) -> None:
67
+ """Checksum for file/directory"""
68
+ # print(hash_mode, save_result, recursive_mode)
69
+ instance = Checksum(file_path, hash_mode=hash_mode, save_result_to_file=save_result)
70
+ res = instance.checksum(recursive=recursive_mode)
71
+ if hash_to_compare is None:
72
+ print(res)
73
+ else:
74
+ print(res == hash_to_compare)
75
+
76
+
77
+ @click.command(name="t2c")
78
+ @click.argument("text", type=str)
79
+ def text2chem(text: str) -> None:
80
+ """Convert text into chemistry symbol"""
81
+ engine = Text2Chemistry()
82
+ out = engine.convert(text)
83
+ print(Text2Chemistry.beautify_result(out))
84
+
85
+
86
+ @click.command(name="e")
87
+ @click.argument("text", type=str)
88
+ def base64encode(text: str) -> None:
89
+ """Convert text to base64"""
90
+ print(Base64EncodeDecode.encode(text))
91
+
92
+
93
+ @click.command(name="d")
94
+ @click.argument("text", type=str)
95
+ def base64decode(text: str) -> None:
96
+ """Convert base64 to text"""
97
+ print(Base64EncodeDecode.decode(text))
98
+
99
+
100
+ @click.command(name="img")
101
+ @click.option(
102
+ "--data-tag",
103
+ "-d",
104
+ "data_tag",
105
+ type=bool,
106
+ default=False,
107
+ is_flag=True,
108
+ show_default=True,
109
+ help="Add data tag before base64 string",
110
+ )
111
+ @click.argument("img_path", type=str)
112
+ def base64convert_img(img_path: str, data_tag: bool) -> None:
113
+ """Convert img to base64"""
114
+ print(Base64EncodeDecode.encode_image(img_path, data_tag=data_tag))
115
+
116
+
117
+ @click.group(name="b64")
118
+ def base64_group():
119
+ """Base64 encode decode"""
120
+ pass
121
+
122
+
123
+ base64_group.add_command(base64encode)
124
+ base64_group.add_command(base64decode)
125
+ base64_group.add_command(base64convert_img)
126
+
127
+
128
+ @click.group(name="tool")
129
+ def tool_group() -> None:
130
+ """Tools"""
131
+ pass
132
+
133
+
134
+ tool_group.add_command(file_checksum)
135
+ tool_group.add_command(base64_group)
136
+ tool_group.add_command(text2chem)
@@ -3,34 +3,37 @@ Absfuyu: Configuration
3
3
  ----------------------
4
4
  Package configuration module
5
5
 
6
- Version: 2.0.5
7
- Date updated: 14/11/2024 (dd/mm/yyyy)
6
+ Version: 5.0.0
7
+ Date updated: 12/02/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
11
- ###########################################################################
11
+ # ---------------------------------------------------------------------------
12
12
  __all__ = [
13
13
  "ABSFUYU_CONFIG",
14
14
  "Config",
15
+ "CONFIG_PATH",
15
16
  # "Setting"
16
17
  ]
17
18
 
18
19
 
19
20
  # Library
20
- ###########################################################################
21
+ # ---------------------------------------------------------------------------
22
+ from importlib.resources import files
21
23
  from pathlib import Path
22
24
  from typing import Any, TypedDict
23
25
 
24
- from absfuyu.core import CONFIG_PATH
26
+ from absfuyu.core import BaseClass
25
27
  from absfuyu.util.json_method import JsonFile
26
28
 
27
29
  # Setting
28
- ###########################################################################
30
+ # ---------------------------------------------------------------------------
31
+ CONFIG_PATH = files("absfuyu.config").joinpath("config.json")
29
32
  _SPACE_REPLACE = "-" # Replace " " character in setting name
30
33
 
31
34
 
32
35
  # Type hint
33
- ###########################################################################
36
+ # ---------------------------------------------------------------------------
34
37
  class SettingDictFormat(TypedDict):
35
38
  """
36
39
  Format for the ``setting`` section in ``config``
@@ -59,8 +62,8 @@ class ConfigFormat(TypedDict):
59
62
 
60
63
 
61
64
  # Class
62
- ###########################################################################
63
- class Setting:
65
+ # ---------------------------------------------------------------------------
66
+ class Setting(BaseClass):
64
67
  """Setting"""
65
68
 
66
69
  def __init__(self, name: str, value: Any, default: Any, help_: str = "") -> None:
@@ -78,9 +81,6 @@ class Setting:
78
81
  def __str__(self) -> str:
79
82
  return f"{self.__class__.__name__}({self.name}: {self.value})"
80
83
 
81
- def __repr__(self) -> str:
82
- return self.__str__()
83
-
84
84
  @classmethod
85
85
  def from_dict(cls, dict_data: dict[str, SettingDictFormat]):
86
86
  """
@@ -114,7 +114,7 @@ class Setting:
114
114
  return output
115
115
 
116
116
 
117
- class Config:
117
+ class Config(BaseClass):
118
118
  """
119
119
  Config handling
120
120
  """
@@ -126,10 +126,10 @@ class Config:
126
126
  self.config_path: Path = config_file
127
127
  self.json_engine: JsonFile = JsonFile(self.config_path)
128
128
 
129
- if name:
130
- self.name = name
131
- else:
129
+ if name is None:
132
130
  self.name = self.config_path.name
131
+ else:
132
+ self.name = name
133
133
 
134
134
  # Data
135
135
  self.settings: list[Setting] = None # type: ignore
@@ -138,9 +138,6 @@ class Config:
138
138
  def __str__(self) -> str:
139
139
  return f"{self.__class__.__name__}({self.config_path.name})"
140
140
 
141
- def __repr__(self) -> str:
142
- return self.__str__()
143
-
144
141
  # Data prepare and export
145
142
  def _fetch_data(self) -> None:
146
143
  """Load data from ``self.config_file`` file"""
@@ -275,19 +272,5 @@ class Config:
275
272
 
276
273
 
277
274
  # Init
278
- ###########################################################################
275
+ # ---------------------------------------------------------------------------
279
276
  ABSFUYU_CONFIG = Config(CONFIG_PATH) # type: ignore
280
-
281
- # TODO: Create a config file when not available [W.I.P]
282
- # _settings = [
283
- # Setting(
284
- # "auto-install-extra", False, False, "Automatically install required packages"
285
- # ),
286
- # Setting("first-run", True, True, "Check if this package has ever been run"),
287
- # Setting(
288
- # "luckgod-mode",
289
- # False,
290
- # False,
291
- # "A chance that the machine will be randomly shutdown",
292
- # ),
293
- # ]
@@ -0,0 +1,49 @@
1
+ """
2
+ Absfuyu: Core
3
+ -------------
4
+ Bases for other features
5
+
6
+ Version: 5.0.0
7
+ Date updated: 13/02/2025 (dd/mm/yyyy)
8
+ """
9
+
10
+ # Module Package
11
+ # ---------------------------------------------------------------------------
12
+ __all__ = [
13
+ # color
14
+ "CLITextColor",
15
+ # path
16
+ # "CORE_PATH",
17
+ # class
18
+ "ShowAllMethodsMixin",
19
+ "BaseClass",
20
+ # wrapper
21
+ "tqdm",
22
+ "unidecode",
23
+ # decorator
24
+ "deprecated",
25
+ "versionadded",
26
+ "versionchanged",
27
+ ]
28
+
29
+ __package_feature__ = [
30
+ "beautiful", # BeautifulOutput
31
+ "docs", # For (package) hatch's env use only
32
+ "extra", # DataFrame
33
+ "full", # All package
34
+ "dev",
35
+ ]
36
+
37
+
38
+ # Library
39
+ # ---------------------------------------------------------------------------
40
+ # from importlib.resources import files
41
+
42
+ # Most used features are imported to core
43
+ from absfuyu.core.baseclass import BaseClass, CLITextColor, ShowAllMethodsMixin
44
+ from absfuyu.core.docstring import deprecated, versionadded, versionchanged
45
+ from absfuyu.core.dummy_func import tqdm, unidecode
46
+
47
+ # Path
48
+ # ---------------------------------------------------------------------------
49
+ # CORE_PATH = files("absfuyu")