absfuyu 3.3.3__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.

absfuyu/__init__.py CHANGED
@@ -22,7 +22,7 @@ Using in cmd (`absfuyu[cli]` required):
22
22
  __title__ = "absfuyu"
23
23
  __author__ = "AbsoluteWinter"
24
24
  __license__ = "MIT License"
25
- __version__ = "3.3.3"
25
+ __version__ = "3.4.0"
26
26
  __all__ = [
27
27
  "core",
28
28
  "config",
absfuyu/cli/__init__.py CHANGED
@@ -26,7 +26,7 @@ colorama.init(autoreset=True)
26
26
 
27
27
  @click.command()
28
28
  def version() -> None:
29
- """Check current version"""
29
+ """Show current version"""
30
30
  ver_msg = f"{__title__} v{__version__}"
31
31
  click.echo(
32
32
  f"{COLOR['green']}{ver_msg}{COLOR['reset']}\n"
absfuyu/cli/do_group.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Do
5
5
 
6
- Version: 1.0.0
7
- Date updated: 14/04/2024 (dd/mm/yyyy)
6
+ Version: 1.1.0
7
+ Date updated: 15/08/2024 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  __all__ = ["do_group"]
@@ -16,6 +16,7 @@ import click
16
16
  from absfuyu import __title__
17
17
  from absfuyu.cli.color import COLOR
18
18
  from absfuyu.core import __package_feature__
19
+ from absfuyu.general.human import Human2
19
20
  from absfuyu.version import PkgVersion
20
21
 
21
22
 
@@ -65,6 +66,25 @@ def advice() -> None:
65
66
  click.echo(f"{COLOR['green']}{im_bored()}")
66
67
 
67
68
 
69
+ @click.command(name="fs")
70
+ @click.argument("date", type=str)
71
+ @click.argument("number_string", type=str)
72
+ def fs(date: str, number_string: str) -> None:
73
+ """Feng-shui W.I.P"""
74
+
75
+ instance = Human2(date)
76
+ print(instance.fs(number_string))
77
+
78
+
79
+ @click.command(name="info")
80
+ @click.argument("date", type=str)
81
+ def info(date: str) -> None:
82
+ """Day info"""
83
+
84
+ instance = Human2(date)
85
+ print(instance.info())
86
+
87
+
68
88
  @click.group(name="do")
69
89
  def do_group() -> None:
70
90
  """Perform functionalities"""
@@ -74,3 +94,5 @@ def do_group() -> None:
74
94
  do_group.add_command(update)
75
95
  do_group.add_command(install)
76
96
  do_group.add_command(advice)
97
+ do_group.add_command(fs)
98
+ do_group.add_command(info)
@@ -3,8 +3,8 @@ Absfuyu: Data extension
3
3
  -----------------------
4
4
  Extension for data type such as ``list``, ``str``, ``dict``, ...
5
5
 
6
- Version: 1.14.3
7
- Date updated: 05/04/2024 (dd/mm/yyyy)
6
+ Version: 1.15.0
7
+ Date updated: 27/04/2024 (dd/mm/yyyy)
8
8
 
9
9
  Features:
10
10
  ---------
@@ -61,9 +61,9 @@ from typing import (
61
61
  )
62
62
 
63
63
  if _python_version.minor >= 11:
64
- from typing import NotRequired
64
+ from typing import NotRequired, Self
65
65
  else:
66
- from typing_extensions import NotRequired # type: ignore
66
+ from typing_extensions import NotRequired, Self # type: ignore
67
67
 
68
68
  from deprecated.sphinx import versionadded, versionchanged
69
69
 
@@ -256,7 +256,7 @@ class Text(str):
256
256
  split_size: int = 60,
257
257
  split_var_len: int = 12,
258
258
  custom_var_name: Optional[str] = None,
259
- ) -> list:
259
+ ) -> List[str]:
260
260
  """
261
261
  Divide long string into smaller size,
262
262
  then assign a random variable to splited
@@ -277,7 +277,7 @@ class Text(str):
277
277
 
278
278
  Returns
279
279
  -------
280
- list
280
+ list[str]
281
281
  A list in which each item is a smaller
282
282
  string with the size of ``split_size``
283
283
  and a way to concaternate them (when using ``print()``)
@@ -398,7 +398,7 @@ class Text(str):
398
398
 
399
399
  return detail
400
400
 
401
- def reverse(self) -> "Text":
401
+ def reverse(self) -> Self:
402
402
  """
403
403
  Reverse the string
404
404
 
@@ -489,7 +489,7 @@ class Text(str):
489
489
  else:
490
490
  return hex_str
491
491
 
492
- def random_capslock(self, probability: int = 50) -> "Text":
492
+ def random_capslock(self, probability: int = 50) -> Self:
493
493
  """
494
494
  Randomly capslock letter in string
495
495
 
@@ -522,7 +522,7 @@ class Text(str):
522
522
  logger.debug(temp)
523
523
  return self.__class__("".join(temp))
524
524
 
525
- def reverse_capslock(self) -> "Text":
525
+ def reverse_capslock(self) -> Self:
526
526
  """
527
527
  Reverse capslock in string
528
528
 
@@ -934,7 +934,7 @@ class IntNumber(int):
934
934
  except Exception:
935
935
  return False
936
936
 
937
- def reverse(self) -> "IntNumber":
937
+ def reverse(self) -> Self:
938
938
  """
939
939
  Reverse a number. Reverse ``abs(number)`` if ``number < 0``
940
940
 
@@ -983,7 +983,7 @@ class IntNumber(int):
983
983
 
984
984
  # calculation stuff
985
985
  @versionchanged(version="3.3.0", reason="Fix bug")
986
- def lcm(self, with_number: int) -> "IntNumber":
986
+ def lcm(self, with_number: int) -> Self:
987
987
  """
988
988
  Least common multiple of ``self`` and ``with_number``
989
989
 
@@ -1010,7 +1010,7 @@ class IntNumber(int):
1010
1010
  return self.__class__((self * with_number) // math.gcd(self, with_number))
1011
1011
 
1012
1012
  @versionchanged(version="3.3.0", reason="Fix bug")
1013
- def gcd(self, with_number: int) -> "IntNumber":
1013
+ def gcd(self, with_number: int) -> Self:
1014
1014
  """
1015
1015
  Greatest common divisor of ``self`` and ``with_number``
1016
1016
 
@@ -1033,7 +1033,7 @@ class IntNumber(int):
1033
1033
  """
1034
1034
  return self.__class__(math.gcd(self, with_number))
1035
1035
 
1036
- def add_to_one_digit(self, master_number: bool = False) -> "IntNumber":
1036
+ def add_to_one_digit(self, master_number: bool = False) -> Self:
1037
1037
  """
1038
1038
  Convert ``self`` into 1-digit number
1039
1039
  by adding all of the digits together
@@ -1220,7 +1220,7 @@ class ListExt(list):
1220
1220
  ``list`` extension
1221
1221
  """
1222
1222
 
1223
- def stringify(self) -> "ListExt":
1223
+ def stringify(self) -> Self:
1224
1224
  """
1225
1225
  Convert all item in ``list`` into string
1226
1226
 
@@ -1278,7 +1278,7 @@ class ListExt(list):
1278
1278
  )
1279
1279
  return self[::-1][:number_of_items][::-1]
1280
1280
 
1281
- def sorts(self, reverse: bool = False) -> "ListExt":
1281
+ def sorts(self, reverse: bool = False) -> Self:
1282
1282
  """
1283
1283
  Sort all items (with different type) in ``list``
1284
1284
 
@@ -1458,7 +1458,7 @@ class ListExt(list):
1458
1458
  """
1459
1459
  return [self.pick_one() for _ in range(number_of_items)]
1460
1460
 
1461
- def len_items(self) -> "ListExt":
1461
+ def len_items(self) -> Self:
1462
1462
  """
1463
1463
  ``len()`` for every item in ``list[str]``
1464
1464
 
@@ -1499,7 +1499,7 @@ class ListExt(list):
1499
1499
  logger.debug(out)
1500
1500
  return out
1501
1501
 
1502
- def apply(self, func: Callable) -> "ListExt":
1502
+ def apply(self, func: Callable) -> Self:
1503
1503
  """
1504
1504
  Apply function to each entry
1505
1505
 
@@ -1523,7 +1523,7 @@ class ListExt(list):
1523
1523
  # return __class__(func(x) for x in self)
1524
1524
  return self.__class__(map(func, self))
1525
1525
 
1526
- def unique(self) -> "ListExt":
1526
+ def unique(self) -> Self:
1527
1527
  """
1528
1528
  Remove duplicates
1529
1529
 
@@ -1541,7 +1541,7 @@ class ListExt(list):
1541
1541
  """
1542
1542
  return self.__class__(set(self))
1543
1543
 
1544
- def group_by_unique(self) -> "ListExt":
1544
+ def group_by_unique(self) -> Self:
1545
1545
  """
1546
1546
  Group duplicated elements into list
1547
1547
 
@@ -1624,7 +1624,7 @@ class ListExt(list):
1624
1624
 
1625
1625
  return list(x for x, _ in groupby(iter))
1626
1626
 
1627
- def flatten(self) -> "ListExt":
1627
+ def flatten(self) -> Self:
1628
1628
  """
1629
1629
  Flatten the list
1630
1630
 
@@ -1646,7 +1646,7 @@ class ListExt(list):
1646
1646
  temp = list(map(lambda x: x if isinstance(x, list) else [x], self))
1647
1647
  return ListExt(chain(*temp))
1648
1648
 
1649
- def numbering(self, start: int = 0) -> "ListExt":
1649
+ def numbering(self, start: int = 0) -> Self:
1650
1650
  """
1651
1651
  Number the item in list
1652
1652
  (``enumerate`` wrapper)
@@ -1744,7 +1744,7 @@ class DictExt(dict):
1744
1744
  logger.error(err_msg)
1745
1745
  raise ValueError(err_msg) # noqa: B904
1746
1746
 
1747
- def swap_items(self) -> "DictExt":
1747
+ def swap_items(self) -> Self:
1748
1748
  """
1749
1749
  Swap ``dict.keys()`` with ``dict.values()``
1750
1750
 
@@ -1762,7 +1762,7 @@ class DictExt(dict):
1762
1762
  """
1763
1763
  return self.__class__(zip(self.values(), self.keys()))
1764
1764
 
1765
- def apply(self, func: Callable, apply_to_value: bool = True) -> "DictExt":
1765
+ def apply(self, func: Callable, apply_to_value: bool = True) -> Self:
1766
1766
  """
1767
1767
  Apply function to ``DictExt.keys()`` or ``DictExt.values()``
1768
1768
 
@@ -1795,6 +1795,19 @@ class DictExt(dict):
1795
1795
  v = self.values() # type: ignore
1796
1796
  return self.__class__(zip(k, v))
1797
1797
 
1798
+ @versionadded(version="3.4.0")
1799
+ def aggregate(
1800
+ self,
1801
+ other_dict: Dict[Any, Union[int, float]],
1802
+ default_value: Union[int, float] = 0,
1803
+ ) -> Self:
1804
+ """Dict with value type int or float"""
1805
+ out = {
1806
+ k: self.get(k, default_value) + other_dict.get(k, default_value)
1807
+ for k in set(self | other_dict)
1808
+ }
1809
+ return self.__class__(out)
1810
+
1798
1811
 
1799
1812
  # Run
1800
1813
  ###########################################################################
absfuyu/general/human.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Human
3
3
  --------------
4
4
  Human related stuff
5
5
 
6
- Version: 1.3.1
7
- Date updated: 05/04/2024 (dd/mm/yyyy)
6
+ Version: 1.4.0
7
+ Date updated: 15/08/2024 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
@@ -14,13 +14,16 @@ __all__ = ["Human", "Person"]
14
14
 
15
15
  # Library
16
16
  ###########################################################################
17
+ import re
17
18
  from datetime import datetime, time
18
19
  from typing import Optional, Union
20
+ from urllib.parse import urlencode
19
21
 
20
22
  from dateutil.relativedelta import relativedelta
21
23
 
22
24
  from absfuyu.fun import zodiac_sign
23
25
  from absfuyu.general.data_extension import IntNumber
26
+ from absfuyu.tools.web import soup_link
24
27
  from absfuyu.version import Version # type: ignore
25
28
 
26
29
 
@@ -349,7 +352,78 @@ class Person(Human):
349
352
  return IntNumber(temp).add_to_one_digit(master_number=True)
350
353
 
351
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
423
+
424
+
352
425
  # Run
353
426
  ###########################################################################
354
427
  if __name__ == "__main__":
355
- print(Person.JohnDoe().__dict__)
428
+ # print(Person.JohnDoe().__dict__)
429
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: absfuyu
3
- Version: 3.3.3
3
+ Version: 3.4.0
4
4
  Summary: A small collection of code
5
5
  Project-URL: Homepage, https://github.com/AbsoluteWinter/absfuyu-public
6
6
  Project-URL: Documentation, https://absolutewinter.github.io/absfuyu-docs/
@@ -1,4 +1,4 @@
1
- absfuyu/__init__.py,sha256=26MeNqj5nT-GStEbVr6_mBWTADIaRyWIjWDYTadUKL4,638
1
+ absfuyu/__init__.py,sha256=_yzkAdSotbRg7ZyL2DwGHvhipMMNblfJPmT9ApkUZsI,638
2
2
  absfuyu/__main__.py,sha256=OpMwc35W5VANzw6gvlqJaJOl2H89i_frFZbleUQwDss,163
3
3
  absfuyu/core.py,sha256=HYEbVQ_zKFyMje6pwssw53RojT1RwMjZsA0F6jInxMg,1248
4
4
  absfuyu/everything.py,sha256=PGIXlqgxyADFPygohVYVIb7fZz72L_xXrlLX0WImuYg,788
@@ -6,10 +6,10 @@ absfuyu/logger.py,sha256=vT0CniqNv-cNXbtkhu1jaOhehHvlInHQt1PFsna5qIY,13135
6
6
  absfuyu/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  absfuyu/sort.py,sha256=Z9nK15WehmZjlUNwvAOwF4FhV-rFcqlXkCcehNYmo78,6827
8
8
  absfuyu/version.py,sha256=KMaeXNl93L4VU2RnTySoFv23IDyTvHfy84nyatFcKaE,14128
9
- absfuyu/cli/__init__.py,sha256=I2T8ypj2LA3WRnjSllHZzWZBzd5VW5OCVQnqV9IQqFs,1106
9
+ absfuyu/cli/__init__.py,sha256=nKTbe4iPpkjtDDMJwVY36heInKDm1zyek9ags5an7s4,1105
10
10
  absfuyu/cli/color.py,sha256=7M3XqFllt26tv_NR5qKgyTId6wnVADtUB74cDYy8pOQ,497
11
11
  absfuyu/cli/config_group.py,sha256=FsyYm2apSyAA2PAD12CpHAizenRds_QlLf8j0AlLuVo,1230
12
- absfuyu/cli/do_group.py,sha256=bz3fEpsiicvOR-D5tAe6WcPFiYecpH3yqdh2Z5v-GOA,1815
12
+ absfuyu/cli/do_group.py,sha256=HUXmlx11fSrcq4BwAhxDvQXSj6IPiwt4f2OlVR6sFjM,2343
13
13
  absfuyu/cli/game_group.py,sha256=ySpL2hm4VCplhNY0s22kBGI5eFCdJj9fm1T58yftU74,2348
14
14
  absfuyu/config/__init__.py,sha256=Rowa9XlSQiXVRdbL_6wOh7eWAm1jyPG4sPn_WjBj8D0,8650
15
15
  absfuyu/config/config.json,sha256=-ZQnmDuLq0aAFfsrQbSNR3tq5k9Eu9IVUQgYD9htIQM,646
@@ -32,9 +32,9 @@ absfuyu/game/tictactoe.py,sha256=WeWbRTWPsKl_NXdxuL2h5f9Bu8zMvkRxwIf4VIeAiAA,960
32
32
  absfuyu/game/wordle.py,sha256=1RpgB8fBgcL_E2TgbTFXjZHtzthJQysCAl0fbK_LG5w,101336
33
33
  absfuyu/general/__init__.py,sha256=6AJZ7Ul6l8MKaqEwRD2ktQUIBfhTPaDUYDQB7MUQ5rc,2481
34
34
  absfuyu/general/content.py,sha256=7yhl-6Rhyp2geNpuKQkuhxor3EcyovW3COdiYsmjUDI,17441
35
- absfuyu/general/data_extension.py,sha256=M4DTOTtjcVA-kFYOgdCbuy37QjaDcd_v22bb9FVPbdI,49017
35
+ absfuyu/general/data_extension.py,sha256=4jSND6dzLqoQD3LkskxdslTxDMD-scgekgHBfJNOIlQ,49378
36
36
  absfuyu/general/generator.py,sha256=pozKlZgTqKxzwsKR6-tI8Lel0qTjTMubv4T3Zk7ifEQ,9691
37
- absfuyu/general/human.py,sha256=lB7ZiY1RlLV3ZUgO93TluPNAK-UV4S6OS9X7iLYHRfM,9720
37
+ absfuyu/general/human.py,sha256=drZT1nI_YwGMOwZu8pbzf3frM-SUY15cOcnUpc4pzQk,12241
38
38
  absfuyu/pkg_data/__init__.py,sha256=nqlQFF05sgnpPJYbac7gdUULPNy9PUVhW_KL8vGBqhQ,5000
39
39
  absfuyu/pkg_data/chemistry.pkl,sha256=kYWNa_PVffoDnzT8b9Jvimmf_GZshPe1D-SnEKERsLo,4655
40
40
  absfuyu/pkg_data/tarot.pkl,sha256=ssXTCC_BQgslO5F-3a9HivbxFQ6BioIe2E1frPVi2m0,56195
@@ -52,8 +52,8 @@ absfuyu/util/path.py,sha256=_eeroXaHiJTzIyhX65b-gkMQ4tiHjKT_ZFHLFoHCzlo,16620
52
52
  absfuyu/util/performance.py,sha256=vOSlMmKIT_LLM5Dey3ra-iLLEaW5SsBzIR5-dovzB0w,9142
53
53
  absfuyu/util/pkl.py,sha256=ZZf6-PFC2uRGXqARNi0PGH3A0IXwMP0sYPWZJXENvak,1559
54
54
  absfuyu/util/zipped.py,sha256=C0T2XRJcRPqoUiKBbViY2IgFI_47tdGMT9WXLxK1DeM,2570
55
- absfuyu-3.3.3.dist-info/METADATA,sha256=bJRtoRzzpGmXxxA6hVzlR8EGf1n95UiTiRiNnks1M-8,3969
56
- absfuyu-3.3.3.dist-info/WHEEL,sha256=xl5aZkiJYVTjhVaiADvIe6UeUVylGNomrxKZ0Zda1CE,87
57
- absfuyu-3.3.3.dist-info/entry_points.txt,sha256=bW5CgJRTTWJ2Pywojo07sf-YucRPcnHzMmETh5avbX0,79
58
- absfuyu-3.3.3.dist-info/licenses/LICENSE,sha256=_tQM-uZht2y-26_MHcIasBp8gtJ2YmvLOezIbhixrAA,1076
59
- absfuyu-3.3.3.dist-info/RECORD,,
55
+ absfuyu-3.4.0.dist-info/METADATA,sha256=PFKTz0flBfAbXRFCZHcssanawKuqT7BULYqD6t1VWPA,3969
56
+ absfuyu-3.4.0.dist-info/WHEEL,sha256=xl5aZkiJYVTjhVaiADvIe6UeUVylGNomrxKZ0Zda1CE,87
57
+ absfuyu-3.4.0.dist-info/entry_points.txt,sha256=bW5CgJRTTWJ2Pywojo07sf-YucRPcnHzMmETh5avbX0,79
58
+ absfuyu-3.4.0.dist-info/licenses/LICENSE,sha256=_tQM-uZht2y-26_MHcIasBp8gtJ2YmvLOezIbhixrAA,1076
59
+ absfuyu-3.4.0.dist-info/RECORD,,