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
@@ -11,29 +11,30 @@ Usage:
11
11
  >>> from absfuyu.general.content import ContentLoader
12
12
  """
13
13
 
14
+ # TODO: rewrite this
15
+
14
16
  # Module level
15
- ###########################################################################
17
+ # ---------------------------------------------------------------------------
16
18
  __all__ = ["ContentLoader", "Content", "LoadedContent"]
17
19
 
18
20
 
19
21
  # Library
20
- ###########################################################################
22
+ # ---------------------------------------------------------------------------
21
23
  import json
22
24
  import random
23
25
  import re
24
26
  from collections import Counter
25
27
  from itertools import chain
26
28
  from pathlib import Path
27
- from typing import List, Optional
28
-
29
- from unidecode import unidecode
29
+ from typing import Self
30
30
 
31
+ from absfuyu.core import BaseClass, ShowAllMethodsMixin, unidecode
31
32
  from absfuyu.logger import logger
32
33
 
33
34
 
34
35
  # Class
35
- ###########################################################################
36
- class Content:
36
+ # ---------------------------------------------------------------------------
37
+ class Content(BaseClass):
37
38
  """
38
39
  Contain data
39
40
 
@@ -50,10 +51,7 @@ class Content:
50
51
  # return f"{self.data} | {self.tag}"
51
52
  return str(self.data)
52
53
 
53
- def __repr__(self) -> str:
54
- return self.__str__()
55
-
56
- def unidecoded(self) -> "Content":
54
+ def unidecoded(self) -> Self:
57
55
  """
58
56
  Convert data through ``unidecode`` package
59
57
 
@@ -97,7 +95,7 @@ class Content:
97
95
 
98
96
  def handle_address(
99
97
  self, address_separator: str = ",", *, first_item_not_address: bool = True
100
- ) -> "Content":
98
+ ) -> Self:
101
99
  """
102
100
  Handle ``self.data`` as address and then update the address into ``self.tag``
103
101
 
@@ -142,7 +140,7 @@ class Content:
142
140
  return self.__class__([self.data, self.tag])
143
141
 
144
142
 
145
- class LoadedContent(List[Content]):
143
+ class LoadedContent(list[Content], ShowAllMethodsMixin):
146
144
  """
147
145
  Contain list of ``Content``
148
146
  """
@@ -154,7 +152,7 @@ class LoadedContent(List[Content]):
154
152
  def __repr__(self) -> str:
155
153
  return self.__str__()
156
154
 
157
- def apply(self, func) -> "LoadedContent":
155
+ def apply(self, func) -> Self:
158
156
  """
159
157
  Apply function to each entry
160
158
 
@@ -165,7 +163,7 @@ class LoadedContent(List[Content]):
165
163
  return self.__class__(func(x.data) for x in self)
166
164
 
167
165
  @classmethod
168
- def load_from_json(cls, file: Path) -> "LoadedContent":
166
+ def load_from_json(cls, file: Path) -> Self:
169
167
  """
170
168
  Use this method to load data from ``.json`` file from ``to_json()`` method
171
169
 
@@ -202,7 +200,7 @@ class LoadedContent(List[Content]):
202
200
  logger.debug(temp)
203
201
  return Counter(temp)
204
202
 
205
- def filter(self, tag: str) -> "LoadedContent":
203
+ def filter(self, tag: str) -> Self:
206
204
  """
207
205
  Filter out entry with ``tag``
208
206
 
@@ -223,7 +221,7 @@ class LoadedContent(List[Content]):
223
221
  )
224
222
  return self.__class__([x for x in self if tag in x.tag])
225
223
 
226
- def find(self, keyword: str) -> "LoadedContent":
224
+ def find(self, keyword: str) -> Self:
227
225
  """
228
226
  Return all entries that include ``keyword``
229
227
 
@@ -240,7 +238,7 @@ class LoadedContent(List[Content]):
240
238
  logger.debug("No result")
241
239
  return temp
242
240
 
243
- def short_form(self, separator: str = ",") -> List[str]:
241
+ def short_form(self, separator: str = ",") -> list[str]:
244
242
  """
245
243
  Shows only first item when separated by ``separator`` of ``Content.data``
246
244
 
@@ -256,7 +254,7 @@ class LoadedContent(List[Content]):
256
254
  """
257
255
  return [x.short_form(separator) for x in self]
258
256
 
259
- def pick_one(self, tag: Optional[str] = None) -> Content:
257
+ def pick_one(self, tag: str | None = None) -> Content:
260
258
  """
261
259
  Pick a random entry
262
260
 
@@ -279,7 +277,7 @@ class LoadedContent(List[Content]):
279
277
 
280
278
  def handle_address(
281
279
  self, address_separator: str = ",", *, first_item_not_address: bool = True
282
- ) -> "LoadedContent":
280
+ ) -> Self:
283
281
  """
284
282
  Execute ``Content.handle_address()`` on every ``self.data`` of ``Content``
285
283
 
@@ -362,7 +360,7 @@ class LoadedContent(List[Content]):
362
360
  return "\n".join(out)
363
361
 
364
362
 
365
- class ContentLoader:
363
+ class ContentLoader(BaseClass):
366
364
  """
367
365
  This load data from ``.txt`` file
368
366
 
@@ -372,9 +370,9 @@ class ContentLoader:
372
370
 
373
371
  def __init__(
374
372
  self,
375
- file_path: Path,
373
+ file_path: Path | str,
376
374
  characteristic_detect: bool = True,
377
- tag_dictionary: Optional[dict] = None,
375
+ tag_dictionary: dict | None = None,
378
376
  *,
379
377
  comment_symbol: str = "#",
380
378
  split_symbol: str = "|",
@@ -437,12 +435,6 @@ class ContentLoader:
437
435
  self.split_symbol: str = split_symbol
438
436
  self.tag_separate_symbol: str = tag_separate_symbol
439
437
 
440
- def __str__(self) -> str:
441
- return f"{self.__class__.__name__}({self.__dict__})"
442
-
443
- def __repr__(self) -> str:
444
- return self.__str__()
445
-
446
438
  def content_format(self) -> str:
447
439
  """
448
440
  Shows current content format
@@ -462,7 +454,7 @@ class ContentLoader:
462
454
  out = (
463
455
  f"{self.comment_symbol} This line will be ignored\n"
464
456
  f"<content> {self.split_symbol} "
465
- f"<tag1>{self.tag_separate_symbol} <tag2>"
457
+ f"<tag1>{self.tag_separate_symbol} <tag2>, ..., <tag n>"
466
458
  )
467
459
  return out
468
460
 
@@ -557,9 +549,3 @@ class ContentLoader:
557
549
  Loaded content
558
550
  """
559
551
  return LoadedContent(map(Content, self.load()))
560
-
561
-
562
- # Run
563
- ###########################################################################
564
- if __name__ == "__main__":
565
- logger.setLevel(10)
@@ -3,8 +3,8 @@ Absfuyu: Generator
3
3
  ------------------
4
4
  This generate stuff (Not python's ``generator``)
5
5
 
6
- Version: 1.1.1
7
- Date updated: 05/04/2024 (dd/mm/yyyy)
6
+ Version: 5.0.0
7
+ Date updated: 25/02/2025 (dd/mm/yyyy)
8
8
 
9
9
  Features:
10
10
  ---------
@@ -15,32 +15,23 @@ Features:
15
15
  """
16
16
 
17
17
  # Module level
18
- ###########################################################################
18
+ # ---------------------------------------------------------------------------
19
19
  __all__ = ["Charset", "Generator"]
20
20
 
21
21
 
22
22
  # Library
23
- ###########################################################################
23
+ # ---------------------------------------------------------------------------
24
24
  import string
25
25
  from itertools import chain, combinations
26
26
  from random import choice
27
27
 
28
- # from string import (
29
- # ascii_letters as _ascii_letters,
30
- # ascii_uppercase as _ascii_uppercase,
31
- # ascii_lowercase as _ascii_lowercase,
32
- # digits as _digits,
33
- # printable as _printable,
34
- # punctuation as _punctuation,
35
- # )
36
- from typing import List
37
-
28
+ from absfuyu.core import BaseClass
38
29
  from absfuyu.logger import logger
39
30
  from absfuyu.util import set_max, set_min_max
40
31
 
41
32
 
42
33
  # Class
43
- ###########################################################################
34
+ # ---------------------------------------------------------------------------
44
35
  class Charset:
45
36
  """
46
37
  Character set data class
@@ -55,14 +46,6 @@ class Charset:
55
46
  SPECIAL = string.punctuation
56
47
  ALL = string.printable
57
48
  PRODUCT_KEY = "BCDFGHJKMNPQRTVWXY2346789" # Charset that various key makers use
58
- # DEFAULT = _ascii_letters + _digits
59
- # ALPHABET = _ascii_letters
60
- # FULL = _ascii_letters + _digits + _punctuation
61
- # UPPERCASE = _ascii_uppercase
62
- # LOWERCASE = _ascii_lowercase
63
- # DIGIT = _digits
64
- # SPECIAL = _punctuation
65
- # ALL = _printable
66
49
 
67
50
  def __str__(self) -> str:
68
51
  charset = [x for x in self.__class__.__dict__.keys() if not x.startswith("__")]
@@ -72,20 +55,11 @@ class Charset:
72
55
  return self.__str__()
73
56
 
74
57
 
75
- class Generator:
58
+ class Generator(BaseClass):
76
59
  """
77
60
  Generator that generate stuffs
78
61
  """
79
62
 
80
- def __init__(self) -> None:
81
- logger.debug("Class initiated!")
82
-
83
- def __str__(self) -> str:
84
- return f"{self.__class__.__name__}()"
85
-
86
- def __repr__(self) -> str:
87
- return self.__str__()
88
-
89
63
  @staticmethod
90
64
  def generate_string(
91
65
  charset: str = Charset.DEFAULT,
@@ -173,8 +147,9 @@ class Generator:
173
147
  else:
174
148
  return unique_string
175
149
 
176
- @staticmethod
150
+ @classmethod
177
151
  def generate_key(
152
+ cls,
178
153
  charset: str = Charset.PRODUCT_KEY,
179
154
  letter_per_block: int = 5,
180
155
  number_of_block: int = 5,
@@ -213,7 +188,7 @@ class Generator:
213
188
  'VKKPJVYD2H-M7R687QCV2'
214
189
  """
215
190
  out = sep.join(
216
- __class__.generate_string( # type: ignore
191
+ cls.generate_string(
217
192
  charset,
218
193
  size=letter_per_block,
219
194
  times=number_of_block,
@@ -285,7 +260,7 @@ class Generator:
285
260
  @staticmethod
286
261
  def combinations_range(
287
262
  sequence: list, *, min_len: int = 1, max_len: int = 0
288
- ) -> List[tuple]:
263
+ ) -> list[tuple]:
289
264
  """
290
265
  Generate all combinations of a ``sequence`` from ``min_len`` to ``max_len``
291
266
 
@@ -306,6 +281,12 @@ class Generator:
306
281
  -------
307
282
  list[tuple]
308
283
  A list of all combinations from range(``min_len``, ``max_len``) of ``sequence``
284
+
285
+
286
+ Example:
287
+ --------
288
+ >>> Generator.combinations_range([1, 2, 3], min_len=2)
289
+ [(1, 2), (1, 3), (2, 3), (1, 2, 3)]
309
290
  """
310
291
  # Restrain
311
292
  if max_len < 1:
@@ -320,9 +301,3 @@ class Generator:
320
301
  [list(combinations(sequence, i)) for i in range(min_len, max_len + 1)]
321
302
  )
322
303
  )
323
-
324
-
325
- # Run
326
- ###########################################################################
327
- if __name__ == "__main__":
328
- logger.setLevel(10) # DEBUG