absfuyu 3.2.0__py3-none-any.whl → 3.4.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 (61) hide show
  1. absfuyu/__init__.py +3 -10
  2. absfuyu/__main__.py +5 -250
  3. absfuyu/cli/__init__.py +51 -0
  4. absfuyu/cli/color.py +24 -0
  5. absfuyu/cli/config_group.py +56 -0
  6. absfuyu/cli/do_group.py +98 -0
  7. absfuyu/cli/game_group.py +109 -0
  8. absfuyu/config/__init__.py +55 -94
  9. absfuyu/config/config.json +0 -7
  10. absfuyu/core.py +5 -66
  11. absfuyu/everything.py +7 -9
  12. absfuyu/extensions/beautiful.py +30 -23
  13. absfuyu/extensions/dev/__init__.py +11 -8
  14. absfuyu/extensions/dev/password_hash.py +4 -2
  15. absfuyu/extensions/dev/passwordlib.py +7 -5
  16. absfuyu/extensions/dev/project_starter.py +4 -2
  17. absfuyu/extensions/dev/shutdownizer.py +148 -0
  18. absfuyu/extensions/extra/__init__.py +1 -2
  19. absfuyu/extensions/extra/data_analysis.py +110 -58
  20. absfuyu/fun/WGS.py +50 -26
  21. absfuyu/fun/__init__.py +6 -7
  22. absfuyu/fun/tarot.py +1 -1
  23. absfuyu/game/__init__.py +75 -81
  24. absfuyu/game/game_stat.py +36 -0
  25. absfuyu/game/sudoku.py +41 -48
  26. absfuyu/game/tictactoe.py +303 -548
  27. absfuyu/game/wordle.py +56 -47
  28. absfuyu/general/__init__.py +17 -7
  29. absfuyu/general/content.py +16 -15
  30. absfuyu/general/data_extension.py +314 -109
  31. absfuyu/general/generator.py +67 -67
  32. absfuyu/general/human.py +148 -78
  33. absfuyu/logger.py +94 -68
  34. absfuyu/pkg_data/__init__.py +29 -25
  35. absfuyu/py.typed +0 -0
  36. absfuyu/sort.py +61 -47
  37. absfuyu/tools/__init__.py +0 -1
  38. absfuyu/tools/converter.py +80 -62
  39. absfuyu/tools/keygen.py +62 -67
  40. absfuyu/tools/obfuscator.py +57 -53
  41. absfuyu/tools/stats.py +24 -24
  42. absfuyu/tools/web.py +10 -9
  43. absfuyu/util/__init__.py +38 -40
  44. absfuyu/util/api.py +53 -43
  45. absfuyu/util/json_method.py +25 -27
  46. absfuyu/util/lunar.py +20 -24
  47. absfuyu/util/path.py +362 -241
  48. absfuyu/util/performance.py +36 -98
  49. absfuyu/util/pkl.py +8 -8
  50. absfuyu/util/zipped.py +17 -19
  51. absfuyu/version.py +137 -148
  52. absfuyu-3.4.0.dist-info/METADATA +124 -0
  53. absfuyu-3.4.0.dist-info/RECORD +59 -0
  54. {absfuyu-3.2.0.dist-info → absfuyu-3.4.0.dist-info}/WHEEL +1 -2
  55. {absfuyu-3.2.0.dist-info → absfuyu-3.4.0.dist-info}/entry_points.txt +1 -0
  56. {absfuyu-3.2.0.dist-info → absfuyu-3.4.0.dist-info/licenses}/LICENSE +1 -1
  57. absfuyu/extensions/dev/pkglib.py +0 -98
  58. absfuyu/game/tictactoe2.py +0 -318
  59. absfuyu-3.2.0.dist-info/METADATA +0 -216
  60. absfuyu-3.2.0.dist-info/RECORD +0 -55
  61. absfuyu-3.2.0.dist-info/top_level.txt +0 -1
absfuyu/general/human.py CHANGED
@@ -3,29 +3,28 @@ Absfuyu: Human
3
3
  --------------
4
4
  Human related stuff
5
5
 
6
- Version: 1.3.0
7
- Date updated: 08/12/2023 (dd/mm/yyyy)
6
+ Version: 1.4.0
7
+ Date updated: 15/08/2024 (dd/mm/yyyy)
8
8
  """
9
9
 
10
-
11
10
  # Module level
12
11
  ###########################################################################
13
- __all__ = [
14
- "Human", "Person"
15
- ]
12
+ __all__ = ["Human", "Person"]
16
13
 
17
14
 
18
15
  # Library
19
16
  ###########################################################################
17
+ import re
20
18
  from datetime import datetime, time
21
19
  from typing import Optional, Union
20
+ from urllib.parse import urlencode
22
21
 
23
22
  from dateutil.relativedelta import relativedelta
24
23
 
25
- from absfuyu.general.data_extension import IntNumber
26
24
  from absfuyu.fun import zodiac_sign
27
- # from absfuyu.util import set_min_max
28
- from absfuyu.version import Version
25
+ from absfuyu.general.data_extension import IntNumber
26
+ from absfuyu.tools.web import soup_link
27
+ from absfuyu.version import Version # type: ignore
29
28
 
30
29
 
31
30
  # Sub-Class
@@ -77,17 +76,17 @@ class Human:
77
76
  Basic human data
78
77
  """
79
78
 
80
- __MEASUREMENT = "m|kg" # Metric system
81
- __VERSION = Version(1, 1, 1) # Internal version class check
79
+ __MEASUREMENT = "m|kg" # Metric system
80
+ __VERSION = Version(1, 1, 1) # Internal version class check
82
81
 
83
82
  def __init__(
84
- self,
85
- first_name: str,
86
- last_name: Optional[str] = None,
87
- birthday: Union[str, datetime, None] = None,
88
- birth_time: Optional[str] = None,
89
- gender: Union[bool, None] = None
90
- ) -> None:
83
+ self,
84
+ first_name: str,
85
+ last_name: Optional[str] = None,
86
+ birthday: Union[str, datetime, None] = None,
87
+ birth_time: Optional[str] = None,
88
+ gender: Union[bool, None] = None,
89
+ ) -> None:
91
90
  """
92
91
  :param first_name: First name
93
92
  :param last_name: Last name
@@ -98,16 +97,22 @@ class Human:
98
97
  # Name
99
98
  self.first_name = first_name
100
99
  self.last_name = last_name
101
- self.name = f"{self.last_name}, {self.first_name}" if self.last_name is not None else self.first_name
100
+ self.name = (
101
+ f"{self.last_name}, {self.first_name}"
102
+ if self.last_name is not None
103
+ else self.first_name
104
+ )
102
105
 
103
106
  # Birthday
104
107
  now = datetime.now()
105
108
  if birthday is None:
106
109
  modified_birthday = now.date()
107
- else:
110
+ elif isinstance(birthday, str):
108
111
  for x in ["/", "-"]:
109
112
  birthday = birthday.replace(x, "/")
110
113
  modified_birthday = datetime.strptime(birthday, "%Y/%m/%d")
114
+ else:
115
+ modified_birthday = birthday
111
116
  # birthday = list(map(int, birthday.split("/")))
112
117
  # modified_birthday = date(*birthday)
113
118
  # modified_birthday = date(birthday[0], birthday[1], birthday[2])
@@ -115,11 +120,11 @@ class Human:
115
120
  if birth_time is None:
116
121
  modified_birthtime = now.time()
117
122
  else:
118
- birth_time = list(map(int, birth_time.split(":")))
123
+ birth_time = list(map(int, birth_time.split(":"))) # type: ignore
119
124
  modified_birthtime = time(*birth_time)
120
125
  # modified_birthtime = time(birth_time[0], birth_time[1])
121
-
122
- self.birthday = modified_birthday.date()
126
+
127
+ self.birthday = modified_birthday.date() # type: ignore
123
128
  self.birth_time = modified_birthtime
124
129
 
125
130
  self.birth = datetime(
@@ -127,15 +132,15 @@ class Human:
127
132
  modified_birthday.month,
128
133
  modified_birthday.day,
129
134
  modified_birthtime.hour,
130
- modified_birthtime.minute
135
+ modified_birthtime.minute,
131
136
  )
132
137
 
133
138
  # Others
134
- self.gender: bool = gender # True: Male; False: Female
135
- self.height: float = None # centimeter
136
- self.weight: float = None # kilogram
137
- self.blood_type: Union[str, BloodType] = BloodType.OTHER
138
-
139
+ self.gender: bool = gender # type: ignore # True: Male; False: Female
140
+ self.height: float = None # type: ignore # centimeter
141
+ self.weight: float = None # type: ignore # kilogram
142
+ self.blood_type: Union[str, BloodType] = BloodType.OTHER # type: ignore
143
+
139
144
  def __str__(self) -> str:
140
145
  class_name = self.__class__.__name__
141
146
  return f"{class_name}({str(self.name)})"
@@ -145,7 +150,7 @@ class Human:
145
150
  name = str(self.name)
146
151
  gender = "M" if self.is_male else "F"
147
152
  return f"{class_name}({name} ({self.age}|{gender}))"
148
-
153
+
149
154
  @classmethod
150
155
  def JohnDoe(cls):
151
156
  """
@@ -159,7 +164,7 @@ class Human:
159
164
  temp = cls("John", "Doe", "1980/01/01", "00:00")
160
165
  temp.update({"gender": True, "height": 180, "weight": 80, "blood_type": "O+"})
161
166
  return temp
162
-
167
+
163
168
  @property
164
169
  def is_male(self) -> bool:
165
170
  """
@@ -172,7 +177,7 @@ class Human:
172
177
  | ``False``: Female
173
178
  """
174
179
  return self.gender
175
-
180
+
176
181
  @property
177
182
  def age(self):
178
183
  """
@@ -182,7 +187,7 @@ class Human:
182
187
  -------
183
188
  float
184
189
  Age
185
-
190
+
186
191
  None
187
192
  When unable to get ``self.birthday``
188
193
  """
@@ -191,7 +196,7 @@ class Human:
191
196
  # age = now - self.birthday
192
197
  try:
193
198
  rdelta = relativedelta(now, self.birthday)
194
- except:
199
+ except Exception:
195
200
  date_str = self.birthday
196
201
  if date_str is None:
197
202
  self.birthday = datetime.now().date()
@@ -201,19 +206,19 @@ class Human:
201
206
  date = datetime.strptime(date_str, "%Y/%m/%d")
202
207
  self.birthday = date
203
208
  rdelta = relativedelta(now, self.birthday)
204
- return round(rdelta.years + rdelta.months/12, 2)
209
+ return round(rdelta.years + rdelta.months / 12, 2)
205
210
  else:
206
211
  return None
207
-
212
+
208
213
  @property
209
214
  def is_adult(self):
210
215
  """
211
216
  Check if ``self.age`` >= ``18``
212
-
217
+
213
218
  :rtype: bool
214
219
  """
215
220
  return self.age >= 18
216
-
221
+
217
222
  @property
218
223
  def bmi(self):
219
224
  r"""
@@ -229,7 +234,7 @@ class Human:
229
234
  -------
230
235
  float
231
236
  BMI value
232
-
237
+
233
238
  None
234
239
  When unable to get ``self.height`` and ``self.weight``
235
240
  """
@@ -237,9 +242,9 @@ class Human:
237
242
  temp = self.height / 100
238
243
  bmi = self.weight / (temp * temp)
239
244
  return round(bmi, 2)
240
- except:
245
+ except Exception:
241
246
  return None
242
-
247
+
243
248
  # @property
244
249
  def dir_(self) -> list:
245
250
  """
@@ -251,7 +256,7 @@ class Human:
251
256
  List of available properties
252
257
  """
253
258
  return [x for x in self.__dir__() if not x.startswith("_")]
254
-
259
+
255
260
  def update(self, data: dict) -> None:
256
261
  """
257
262
  Update Human data
@@ -260,7 +265,7 @@ class Human:
260
265
  ----------
261
266
  data : dict
262
267
  Data
263
-
268
+
264
269
  Returns
265
270
  -------
266
271
  None
@@ -274,29 +279,29 @@ class Person(Human):
274
279
  More detailed ``Human`` data
275
280
  """
276
281
 
277
- __VERSION = Version(1, 1, 1) # Internal version class check
282
+ __VERSION = Version(1, 1, 1) # Internal version class check
278
283
 
279
284
  def __init__(
280
- self,
281
- first_name: str,
282
- last_name: Optional[str] = None,
283
- birthday: Union[str, datetime, None] = None,
284
- birth_time: Optional[str] = None,
285
- gender: Union[bool, None] = None
286
- ) -> None:
285
+ self,
286
+ first_name: str,
287
+ last_name: Optional[str] = None,
288
+ birthday: Union[str, datetime, None] = None,
289
+ birth_time: Optional[str] = None,
290
+ gender: Union[bool, None] = None,
291
+ ) -> None:
287
292
  super().__init__(first_name, last_name, birthday, birth_time, gender)
288
- self.address: str = None
289
- self.hometown: str = None
290
- self.email: str = None
291
- self.phone_number: str = None
292
- self.nationality = None
293
- self.likes: list = None
294
- self.hates: list = None
295
- self.education = None
296
- self.occupation: str = None
297
- self.personality = None
298
- self.note: str = None
299
-
293
+ self.address: str = None # type: ignore
294
+ self.hometown: str = None # type: ignore
295
+ self.email: str = None # type: ignore
296
+ self.phone_number: str = None # type: ignore
297
+ self.nationality = None # type: ignore
298
+ self.likes: list = None # type: ignore
299
+ self.hates: list = None # type: ignore
300
+ self.education = None # type: ignore
301
+ self.occupation: str = None # type: ignore
302
+ self.personality = None # type: ignore
303
+ self.note: str = None # type: ignore
304
+
300
305
  @property
301
306
  def zodiac_sign(self):
302
307
  """
@@ -306,15 +311,15 @@ class Person(Human):
306
311
  -------
307
312
  str
308
313
  Zodiac sign
309
-
314
+
310
315
  None
311
316
  When unable to get ``self.birthday``
312
317
  """
313
318
  try:
314
319
  return zodiac_sign(self.birthday.day, self.birthday.month)
315
- except:
320
+ except Exception:
316
321
  return None
317
-
322
+
318
323
  @property
319
324
  def zodiac_sign_13(self):
320
325
  """
@@ -324,15 +329,15 @@ class Person(Human):
324
329
  -------
325
330
  str
326
331
  Zodiac sign
327
-
332
+
328
333
  None
329
334
  When unable to get ``self.birthday``
330
335
  """
331
336
  try:
332
337
  return zodiac_sign(self.birthday.day, self.birthday.month, zodiac13=True)
333
- except:
338
+ except Exception:
334
339
  return None
335
-
340
+
336
341
  @property
337
342
  def numerology(self) -> int:
338
343
  """
@@ -342,18 +347,83 @@ class Person(Human):
342
347
  -------
343
348
  int
344
349
  Numerology number
345
-
346
- None
347
- When unable to get ``self.birthday``
348
350
  """
349
- try:
350
- temp = f"{self.birthday.year}{self.birthday.month}{self.birthday.day}"
351
- return IntNumber(temp).add_to_one_digit(master_number=True)
352
- except:
353
- return None
351
+ temp = f"{self.birthday.year}{self.birthday.month}{self.birthday.day}"
352
+ return IntNumber(temp).add_to_one_digit(master_number=True)
353
+
354
+
355
+ class Human2:
356
+ """W.I.P for cli"""
357
+
358
+ def __init__(self, birthday_string: str, is_male: bool = True) -> None:
359
+ """
360
+ :param birthday_string: Format ``<yyyymmddhhmm>`` or ``<yyyymmdd>``
361
+ """
362
+ if len(birthday_string) == 12:
363
+ day = datetime(
364
+ year=int(birthday_string[:4]),
365
+ month=int(birthday_string[4:6]),
366
+ day=int(birthday_string[6:8]),
367
+ hour=int(birthday_string[8:10]),
368
+ minute=int(birthday_string[10:]),
369
+ )
370
+ else:
371
+ day = datetime(
372
+ year=int(birthday_string[:4]),
373
+ month=int(birthday_string[4:6]),
374
+ day=int(birthday_string[6:]),
375
+ )
376
+ self._date_str = birthday_string[:8]
377
+ self.day = day
378
+ self.is_male = is_male
379
+
380
+ def __str__(self) -> str:
381
+ class_name = self.__class__.__name__
382
+ return f"{class_name}({str(self.day)})"
383
+
384
+ def __repr__(self) -> str:
385
+ class_name = self.__class__.__name__
386
+ return f"{class_name}({str(self.day)})"
387
+
388
+ def numerology(self) -> int:
389
+ # numerology
390
+ return IntNumber(self._date_str).add_to_one_digit(master_number=True)
391
+
392
+ def _make_fengshui_check_query(self) -> str:
393
+ """
394
+ Generate query to check Feng-shui
395
+ """
396
+ params = {
397
+ "ngay": self.day.day.__str__().rjust(2, "0"),
398
+ "thang": self.day.month.__str__().rjust(2, "0"),
399
+ "nam": self.day.year,
400
+ "gio": self.day.hour.__str__().rjust(2, "0"),
401
+ "phut": self.day.minute.__str__().rjust(2, "0"),
402
+ "gioitinh": "nam" if self.is_male else "nu",
403
+ }
404
+ output = urlencode(params)
405
+ return output
406
+
407
+ def fs(self, number_string: str) -> float:
408
+ # fengshui
409
+ base = "https://thanglongdaoquan.vn/boi-so-tai-khoan/?taikhoan="
410
+ link = f"{base}{number_string}&{self._make_fengshui_check_query()}"
411
+ soup = soup_link(link)
412
+ val = soup.find_all(class_="total_point")[0].get_text()
413
+ pattern = r"([0-9.]{1,3})/10"
414
+ res = re.findall(pattern, val)[0]
415
+ return float(res)
416
+
417
+ def info(self) -> dict:
418
+ out = {
419
+ "numerology": self.numerology(),
420
+ "zodiac": zodiac_sign(self.day.day, self.day.month),
421
+ }
422
+ return out
354
423
 
355
424
 
356
425
  # Run
357
426
  ###########################################################################
358
427
  if __name__ == "__main__":
359
- print(Person.JohnDoe().__dict__)
428
+ # print(Person.JohnDoe().__dict__)
429
+ pass