absfuyu 4.2.0__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 (67) hide show
  1. absfuyu/__init__.py +4 -4
  2. absfuyu/__main__.py +13 -1
  3. absfuyu/cli/color.py +7 -0
  4. absfuyu/cli/do_group.py +0 -35
  5. absfuyu/cli/tool_group.py +5 -5
  6. absfuyu/config/__init__.py +17 -34
  7. absfuyu/core/__init__.py +49 -0
  8. absfuyu/core/baseclass.py +299 -0
  9. absfuyu/core/baseclass2.py +165 -0
  10. absfuyu/core/decorator.py +67 -0
  11. absfuyu/core/docstring.py +163 -0
  12. absfuyu/core/dummy_cli.py +67 -0
  13. absfuyu/core/dummy_func.py +47 -0
  14. absfuyu/dxt/__init__.py +42 -0
  15. absfuyu/dxt/dictext.py +201 -0
  16. absfuyu/dxt/dxt_support.py +79 -0
  17. absfuyu/dxt/intext.py +586 -0
  18. absfuyu/dxt/listext.py +508 -0
  19. absfuyu/dxt/strext.py +530 -0
  20. absfuyu/{extensions → extra}/__init__.py +2 -2
  21. absfuyu/extra/beautiful.py +251 -0
  22. absfuyu/{extensions → extra}/data_analysis.py +51 -82
  23. absfuyu/fun/__init__.py +110 -135
  24. absfuyu/fun/tarot.py +9 -17
  25. absfuyu/game/__init__.py +6 -0
  26. absfuyu/game/game_stat.py +6 -0
  27. absfuyu/game/sudoku.py +7 -1
  28. absfuyu/game/tictactoe.py +12 -5
  29. absfuyu/game/wordle.py +14 -8
  30. absfuyu/general/__init__.py +6 -79
  31. absfuyu/general/content.py +22 -36
  32. absfuyu/general/generator.py +17 -42
  33. absfuyu/general/human.py +108 -228
  34. absfuyu/general/shape.py +1334 -0
  35. absfuyu/logger.py +8 -13
  36. absfuyu/pkg_data/__init__.py +136 -99
  37. absfuyu/pkg_data/deprecated.py +133 -0
  38. absfuyu/sort.py +6 -130
  39. absfuyu/tools/__init__.py +2 -2
  40. absfuyu/tools/checksum.py +33 -22
  41. absfuyu/tools/converter.py +51 -48
  42. absfuyu/tools/keygen.py +25 -30
  43. absfuyu/tools/obfuscator.py +246 -112
  44. absfuyu/tools/passwordlib.py +99 -29
  45. absfuyu/tools/shutdownizer.py +68 -47
  46. absfuyu/tools/web.py +2 -9
  47. absfuyu/util/__init__.py +15 -15
  48. absfuyu/util/api.py +10 -15
  49. absfuyu/util/json_method.py +7 -24
  50. absfuyu/util/lunar.py +3 -9
  51. absfuyu/util/path.py +22 -27
  52. absfuyu/util/performance.py +43 -67
  53. absfuyu/util/shorten_number.py +65 -14
  54. absfuyu/util/zipped.py +9 -15
  55. {absfuyu-4.2.0.dist-info → absfuyu-5.0.0.dist-info}/METADATA +41 -14
  56. absfuyu-5.0.0.dist-info/RECORD +68 -0
  57. absfuyu/core.py +0 -57
  58. absfuyu/everything.py +0 -32
  59. absfuyu/extensions/beautiful.py +0 -188
  60. absfuyu/fun/WGS.py +0 -134
  61. absfuyu/general/data_extension.py +0 -1796
  62. absfuyu/tools/stats.py +0 -226
  63. absfuyu/util/pkl.py +0 -67
  64. absfuyu-4.2.0.dist-info/RECORD +0 -59
  65. {absfuyu-4.2.0.dist-info → absfuyu-5.0.0.dist-info}/WHEEL +0 -0
  66. {absfuyu-4.2.0.dist-info → absfuyu-5.0.0.dist-info}/entry_points.txt +0 -0
  67. {absfuyu-4.2.0.dist-info → absfuyu-5.0.0.dist-info}/licenses/LICENSE +0 -0
absfuyu/tools/checksum.py CHANGED
@@ -3,33 +3,35 @@ Absufyu: Checksum
3
3
  -----------------
4
4
  Check MD5, SHA256, ...
5
5
 
6
- Version: 1.1.1
7
- Date updated: 05/02/2025 (dd/mm/yyyy)
6
+ Version: 5.0.0
7
+ Date updated: 13/02/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
11
- ###########################################################################
12
- __all__ = ["Checksum", "checksum_operation"]
11
+ # ---------------------------------------------------------------------------
12
+ __all__ = ["Checksum", "ChecksumMode"]
13
13
 
14
14
 
15
15
  # Library
16
- ###########################################################################
16
+ # ---------------------------------------------------------------------------
17
17
  import hashlib
18
+ from enum import StrEnum
18
19
  from pathlib import Path
19
20
  from typing import Literal
20
21
 
21
- from absfuyu.core import tqdm
22
-
23
- # Function
24
- ###########################################################################
22
+ from absfuyu.core import BaseClass, deprecated, tqdm, versionadded, versionchanged
25
23
 
26
24
 
27
- # Deprecated
28
- def checksum_operation(
25
+ # Function
26
+ # ---------------------------------------------------------------------------
27
+ @deprecated("5.0.0")
28
+ def _checksum_operation(
29
29
  file: Path | str,
30
30
  hash_mode: str | Literal["md5", "sha1", "sha256", "sha512"] = "sha256",
31
31
  ) -> str:
32
- """This performs checksum"""
32
+ """
33
+ This performs checksum
34
+ """
33
35
  if hash_mode.lower() == "md5":
34
36
  hash_engine = hashlib.md5()
35
37
  elif hash_mode.lower() == "sha1":
@@ -51,11 +53,24 @@ def checksum_operation(
51
53
  return hash_engine.hexdigest()
52
54
 
53
55
 
54
- class Checksum:
56
+ # Class
57
+ # ---------------------------------------------------------------------------
58
+ class ChecksumMode(StrEnum):
59
+ MD5 = "md5"
60
+ SHA1 = "sha1"
61
+ SHA256 = "sha256"
62
+ SHA512 = "sha512"
63
+
64
+
65
+ @versionchanged("4.1.1", reason="Checksum for entire folder is possible")
66
+ @versionadded("4.1.0")
67
+ class Checksum(BaseClass):
55
68
  def __init__(
56
69
  self,
57
70
  path: str | Path,
58
- hash_mode: str | Literal["md5", "sha1", "sha256", "sha512"] = "sha256",
71
+ hash_mode: (
72
+ ChecksumMode | Literal["md5", "sha1", "sha256", "sha512"]
73
+ ) = ChecksumMode.SHA256,
59
74
  save_result_to_file: bool = False,
60
75
  ) -> None:
61
76
  """Checksum engine
@@ -64,8 +79,10 @@ class Checksum:
64
79
  ----------
65
80
  path : str | Path
66
81
  Path to file/directory to perform checksum
67
- hash_mode : str | Literal["md5", "sha1", "sha256", "sha512"], optional
68
- Hash mode, by default "sha256"
82
+
83
+ hash_mode : ChecksumMode | Literal["md5", "sha1", "sha256", "sha512"], optional
84
+ Hash mode, by default ``"sha256"``
85
+
69
86
  save_result_to_file : bool, optional
70
87
  Save checksum result(s) to file, by default False
71
88
  """
@@ -146,9 +163,3 @@ class Checksum:
146
163
  f.write(output)
147
164
 
148
165
  return output
149
-
150
-
151
- # Run
152
- ###########################################################################
153
- if __name__ == "__main__":
154
- pass
@@ -3,8 +3,8 @@ Absufyu: Converter
3
3
  ------------------
4
4
  Convert stuff
5
5
 
6
- Version: 1.4.0
7
- Date updated: 10/02/2025 (dd/mm/yyyy)
6
+ Version: 5.0.0
7
+ Date updated: 11/02/2025 (dd/mm/yyyy)
8
8
 
9
9
  Feature:
10
10
  --------
@@ -14,12 +14,16 @@ Feature:
14
14
  """
15
15
 
16
16
  # Module level
17
- ###########################################################################
18
- __all__ = ["Text2Chemistry", "Str2Pixel", "Base64EncodeDecode"]
17
+ # ---------------------------------------------------------------------------
18
+ __all__ = [
19
+ "Text2Chemistry",
20
+ "Str2Pixel",
21
+ "Base64EncodeDecode",
22
+ ]
19
23
 
20
24
 
21
25
  # Library
22
- ###########################################################################
26
+ # ---------------------------------------------------------------------------
23
27
  import base64
24
28
  import math
25
29
  import re
@@ -28,36 +32,41 @@ from itertools import chain, combinations
28
32
  from pathlib import Path
29
33
  from typing import Self
30
34
 
31
- from absfuyu.core import CLITextColor
35
+ from absfuyu.core import BaseClass, CLITextColor, versionadded
32
36
  from absfuyu.logger import logger
33
- from absfuyu.pkg_data import DataList
37
+ from absfuyu.pkg_data import DataList, DataLoader
34
38
  from absfuyu.util import set_min
35
- from absfuyu.util.pkl import Pickler
36
39
 
37
40
 
38
41
  # Class
39
- ###########################################################################
40
- class Base64EncodeDecode:
42
+ # ---------------------------------------------------------------------------
43
+ @versionadded("3.0.0")
44
+ class Base64EncodeDecode(BaseClass):
41
45
  """
42
46
  Encode and decode base64
43
47
  """
44
48
 
45
49
  @staticmethod
46
50
  def encode(data: str) -> str:
51
+ """Base64 encode"""
47
52
  return base64.b64encode(data.encode()).decode()
48
53
 
49
54
  @staticmethod
50
55
  def decode(data: str) -> str:
56
+ """Base64 decode"""
51
57
  return base64.b64decode(data).decode()
52
58
 
53
59
  @staticmethod
60
+ @versionadded("4.1.0")
54
61
  def encode_image(img_path: Path | str, data_tag: bool = False) -> str:
55
- """Encode image file into base64 string
62
+ """
63
+ Encode image file into base64 string
56
64
 
57
65
  Parameters
58
66
  ----------
59
67
  img_path : Path | str
60
68
  Path to image
69
+
61
70
  data_tag : bool, optional
62
71
  Add data tag before base64 string, by default ``False``
63
72
 
@@ -74,7 +83,7 @@ class Base64EncodeDecode:
74
83
  return b64_data
75
84
 
76
85
 
77
- class ChemistryElement:
86
+ class ChemistryElement(BaseClass):
78
87
  """Chemistry Element"""
79
88
 
80
89
  def __init__(self, name: str, number: int, symbol: str, atomic_mass: float) -> None:
@@ -90,10 +99,6 @@ class ChemistryElement:
90
99
  self.atomic_mass = atomic_mass
91
100
 
92
101
  def __str__(self) -> str:
93
- return self.symbol
94
-
95
- def __repr__(self) -> str:
96
- # return self.symbol
97
102
  return f"{self.__class__.__name__}({self.symbol})"
98
103
 
99
104
  def to_dict(self) -> dict[str, str | int | float]:
@@ -126,25 +131,22 @@ class ChemistryElement:
126
131
  )
127
132
 
128
133
 
129
- class Text2Chemistry:
134
+ class Text2Chemistry(BaseClass):
130
135
  def __init__(self) -> None:
131
136
  self.data_location = DataList.CHEMISTRY
132
137
 
133
138
  def __str__(self) -> str:
134
139
  return f"{self.__class__.__name__}()"
135
140
 
136
- def __repr__(self) -> str:
137
- return self.__str__()
138
-
139
141
  def _load_chemistry_data(self) -> list[ChemistryElement]:
140
142
  """
141
143
  Load chemistry pickle data
142
144
  """
143
- data: list[dict] = Pickler.load(self.data_location) # type: ignore
145
+ data: list[dict] = DataLoader(self.data_location).load()
144
146
  return [ChemistryElement.from_dict(x) for x in data]
145
147
 
146
148
  @property
147
- def unvailable_characters(self):
149
+ def unvailable_characters(self) -> set[str]:
148
150
  """
149
151
  Characters that can not be converted (unvailable chemistry symbol)
150
152
 
@@ -231,10 +233,12 @@ class Text2Chemistry:
231
233
  return output
232
234
 
233
235
  @staticmethod
236
+ @versionadded("4.2.0")
234
237
  def beautify_result(
235
238
  result: list[list[ChemistryElement]] | list,
236
- ) -> str: # Added in version 4.2.0
237
- """Beautify the result from ``Text2Chemistry.convert()``
239
+ ) -> str:
240
+ """
241
+ Beautify the result from ``Text2Chemistry.convert()``
238
242
 
239
243
  Parameters
240
244
  ----------
@@ -251,17 +255,18 @@ class Text2Chemistry:
251
255
  else:
252
256
  msg = []
253
257
  for i, solution in enumerate(result, start=1):
258
+ max_word_len = max([len(x.name) for x in solution])
254
259
  msg.append(f"Option {i:02}: {', '.join([x.symbol for x in solution])}")
255
260
  for x in solution:
256
261
  msg.append(
257
- f"{x.symbol} ({x.number}. {x.name} - {round(x.atomic_mass, 2)})"
262
+ f"{x.symbol.ljust(2)} ({x.number:02}. {x.name.ljust(max_word_len)} - {round(x.atomic_mass, 2)})"
258
263
  )
259
264
  msg.append("---")
260
265
  res = "\n".join(msg)
261
266
  return res
262
267
 
263
268
 
264
- class Str2Pixel:
269
+ class Str2Pixel(BaseClass):
265
270
  """Convert str into pixel"""
266
271
 
267
272
  PIXEL = "\u2588"
@@ -274,11 +279,17 @@ class Str2Pixel:
274
279
  pixel_symbol_overwrite: str | None = None,
275
280
  ) -> None:
276
281
  """
277
- str_data: Pixel string data (Format: <number_of_pixel><color_code>)
278
- pixel_size: Pixel size (Default: 2)
279
- pixel_symbol_overwrite: Overwrite pixel symbol (Default: None)
282
+ Parameters
283
+ ----------
284
+ str_data : str
285
+ Pixel string data (Format: ``<number_of_pixel><color_code>``)
286
+ Example: 50w20b = 50 white pixels and 20 black pixels
287
+
288
+ pixel_size : int, optional
289
+ Pixel size, by default ``2``
280
290
 
281
- Example: 50w20b = 50 white pixels and 20 black pixels
291
+ pixel_symbol_overwrite : str | None, optional
292
+ Overwrite pixel symbol, by default ``None``
282
293
  """
283
294
  self.data = str_data
284
295
  if pixel_symbol_overwrite is None:
@@ -286,12 +297,6 @@ class Str2Pixel:
286
297
  else:
287
298
  self.pixel = pixel_symbol_overwrite
288
299
 
289
- def __str__(self) -> str:
290
- return f"{self.__class__.__name__}(pixel={self.pixel})"
291
-
292
- def __repr__(self) -> str:
293
- return self.__str__()
294
-
295
300
  def _extract_pixel(self):
296
301
  """Split str_data into corresponding int and str"""
297
302
  num = re.split("[a-zA-Z]", self.data) # type: ignore
@@ -302,13 +307,17 @@ class Str2Pixel:
302
307
  return [x for y in zip(num, char) for x in y]
303
308
 
304
309
  def convert(self, line_break: bool = True) -> str:
305
- """
306
- Convert data into pixel
310
+ """Convert data into pixel
311
+
312
+ Parameters
313
+ ----------
314
+ line_break : bool, optional
315
+ Add ``\\n`` at the end of line, by default ``True``
307
316
 
308
- :param line_break: add ``\\n`` at the end of line (Default: ``False``)
309
- :type line_break: bool
310
- :returns: Converted colored pixels
311
- :rtype: str
317
+ Returns
318
+ -------
319
+ str
320
+ Converted colored pixels
312
321
  """
313
322
  # Extract pixel
314
323
  pixel_map = self._extract_pixel()
@@ -353,9 +362,3 @@ class Str2Pixel:
353
362
  return out + "\n"
354
363
  else:
355
364
  return out
356
-
357
-
358
- # Run
359
- ###########################################################################
360
- if __name__ == "__main__":
361
- logger.setLevel(10)
absfuyu/tools/keygen.py CHANGED
@@ -5,23 +5,25 @@ Mod7 product key generator (90's)
5
5
 
6
6
  This is for educational and informative purposes only.
7
7
 
8
- Version: 2.0.2
9
- Date updated: 05/04/2024 (dd/mm/yyyy)
8
+ Version: 5.0.0
9
+ Date updated: 25/02/2025 (dd/mm/yyyy)
10
10
  """
11
11
 
12
12
  # Module level
13
- ###########################################################################
13
+ # ---------------------------------------------------------------------------
14
14
  __all__ = ["Keygen"]
15
15
 
16
16
 
17
17
  # Library
18
- ###########################################################################
18
+ # ---------------------------------------------------------------------------
19
19
  import random
20
20
 
21
+ from absfuyu.core import BaseClass
22
+
21
23
 
22
24
  # Class
23
- ###########################################################################
24
- class Keygen:
25
+ # ---------------------------------------------------------------------------
26
+ class Keygen(BaseClass):
25
27
  """Key generator"""
26
28
 
27
29
  @staticmethod
@@ -39,8 +41,8 @@ class Keygen:
39
41
  except Exception:
40
42
  raise ValueError("Invalid string") # noqa: B904
41
43
 
42
- @staticmethod
43
- def _mod7_gen(num_of_digits: int, *, fillchar: str = "0") -> str:
44
+ @classmethod
45
+ def _mod7_gen(cls, num_of_digits: int, *, fillchar: str = "0") -> str:
44
46
  """
45
47
  Generate a number with desired length that is divisible by 7
46
48
 
@@ -76,14 +78,14 @@ class Keygen:
76
78
  continue
77
79
 
78
80
  # Check divide by 7
79
- if __class__._is_mod7(mod7_num): # type: ignore
81
+ if cls._is_mod7(str(mod7_num)):
80
82
  mod7_valid = True
81
83
 
82
84
  # Output
83
85
  return str(mod7_num).rjust(num_of_digits, fillchar)
84
86
 
85
- @staticmethod
86
- def mod7_cd_key(fast: bool = False) -> str:
87
+ @classmethod
88
+ def mod7_cd_key(cls, fast: bool = False) -> str:
87
89
  """
88
90
  CD Key generator
89
91
 
@@ -123,13 +125,13 @@ class Keygen:
123
125
  part1_valid = True # Break loop
124
126
 
125
127
  # PART 02
126
- part2 = __class__._mod7_gen(num_of_digits=7) # type: ignore
128
+ part2 = cls._mod7_gen(num_of_digits=7)
127
129
 
128
130
  # OUTPUT
129
131
  return f"{part1}-{part2}"
130
132
 
131
- @staticmethod
132
- def mod7_11_digit_key(fast: bool = False) -> str:
133
+ @classmethod
134
+ def mod7_11_digit_key(cls, fast: bool = False) -> str:
133
135
  """
134
136
  11-digit CD Key generator
135
137
 
@@ -171,13 +173,13 @@ class Keygen:
171
173
  part1_valid = True
172
174
 
173
175
  # PART 02
174
- part2 = __class__._mod7_gen(num_of_digits=7) # type: ignore
176
+ part2 = cls._mod7_gen(num_of_digits=7)
175
177
 
176
178
  # OUTPUT
177
179
  return f"{part1}-{part2}"
178
180
 
179
- @staticmethod
180
- def mod7_oem_key(fast: bool = False) -> str:
181
+ @classmethod
182
+ def mod7_oem_key(cls, fast: bool = False) -> str:
181
183
  """
182
184
  OEM Key generator
183
185
 
@@ -214,7 +216,7 @@ class Keygen:
214
216
  y_part = random.choice(year_choice)
215
217
 
216
218
  # NUM PART
217
- num_part = __class__._mod7_gen(num_of_digits=6) # type: ignore
219
+ num_part = cls._mod7_gen(num_of_digits=6)
218
220
 
219
221
  # NUM PART 02
220
222
  num_part_2 = str(random.randint(0, 99999)).rjust(5, "0")
@@ -222,8 +224,8 @@ class Keygen:
222
224
  # OUTPUT
223
225
  return f"{abc_part}{y_part}-OEM-0{num_part}-{num_part_2}"
224
226
 
225
- @staticmethod
226
- def mod7_combo(fast: bool = False):
227
+ @classmethod
228
+ def mod7_combo(cls, fast: bool = False):
227
229
  """
228
230
  A combo that consist of CD, 11-digit, and OEM Key
229
231
 
@@ -239,15 +241,8 @@ class Keygen:
239
241
  Mod7 Key combo
240
242
  """
241
243
  out = {
242
- "CD Key": __class__.mod7_cd_key(fast=fast), # type: ignore
243
- "OEM Key": __class__.mod7_oem_key(fast=fast), # type: ignore
244
- "11-digit Key": __class__.mod7_11_digit_key(fast=fast), # type: ignore
244
+ "CD Key": cls.mod7_cd_key(fast=fast),
245
+ "OEM Key": cls.mod7_oem_key(fast=fast),
246
+ "11-digit Key": cls.mod7_11_digit_key(fast=fast),
245
247
  }
246
248
  return out
247
-
248
-
249
- # Run
250
- ###########################################################################
251
- if __name__ == "__main__":
252
- test = Keygen()
253
- print(test.mod7_combo())