absfuyu 4.1.0__tar.gz → 4.2.0__tar.gz

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 (94) hide show
  1. {absfuyu-4.1.0 → absfuyu-4.2.0}/PKG-INFO +13 -18
  2. absfuyu-4.2.0/README.md +66 -0
  3. {absfuyu-4.1.0 → absfuyu-4.2.0}/pyproject.toml +4 -3
  4. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/__init__.py +1 -1
  5. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/cli/__init__.py +4 -2
  6. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/cli/do_group.py +14 -38
  7. absfuyu-4.2.0/src/absfuyu/cli/tool_group.py +136 -0
  8. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/core.py +4 -5
  9. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/extensions/__init__.py +1 -0
  10. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/pkg_data/__init__.py +2 -1
  11. absfuyu-4.2.0/src/absfuyu/pkg_data/passwordlib_lzma.pkl +0 -0
  12. absfuyu-4.2.0/src/absfuyu/tools/checksum.py +154 -0
  13. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/tools/converter.py +36 -7
  14. {absfuyu-4.1.0/src/absfuyu/extensions/dev → absfuyu-4.2.0/src/absfuyu/tools}/passwordlib.py +52 -50
  15. absfuyu-4.2.0/src/absfuyu/tools/shutdownizer.py +266 -0
  16. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/shorten_number.py +1 -1
  17. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_data_analysis.py +1 -1
  18. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_everything.py +12 -4
  19. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_passwordlib.py +4 -9
  20. absfuyu-4.1.0/README.md +0 -68
  21. absfuyu-4.1.0/src/absfuyu/extensions/dev/__init__.py +0 -244
  22. absfuyu-4.1.0/src/absfuyu/extensions/dev/password_hash.py +0 -80
  23. absfuyu-4.1.0/src/absfuyu/extensions/dev/project_starter.py +0 -60
  24. absfuyu-4.1.0/src/absfuyu/extensions/dev/shutdownizer.py +0 -156
  25. absfuyu-4.1.0/src/absfuyu/extensions/extra/__init__.py +0 -24
  26. absfuyu-4.1.0/src/absfuyu/tools/checksum.py +0 -56
  27. {absfuyu-4.1.0 → absfuyu-4.2.0}/.gitignore +0 -0
  28. {absfuyu-4.1.0 → absfuyu-4.2.0}/LICENSE +0 -0
  29. {absfuyu-4.1.0 → absfuyu-4.2.0}/dev_requirements.txt +0 -0
  30. {absfuyu-4.1.0 → absfuyu-4.2.0}/docs/Makefile +0 -0
  31. {absfuyu-4.1.0 → absfuyu-4.2.0}/docs/conf.py +0 -0
  32. {absfuyu-4.1.0 → absfuyu-4.2.0}/docs/index.rst +0 -0
  33. {absfuyu-4.1.0 → absfuyu-4.2.0}/docs/info.md +0 -0
  34. {absfuyu-4.1.0 → absfuyu-4.2.0}/docs/make.bat +0 -0
  35. {absfuyu-4.1.0 → absfuyu-4.2.0}/docs/modules.rst +0 -0
  36. {absfuyu-4.1.0 → absfuyu-4.2.0}/images/repository-image-crop.png +0 -0
  37. {absfuyu-4.1.0 → absfuyu-4.2.0}/images/repository-image-white.png +0 -0
  38. {absfuyu-4.1.0 → absfuyu-4.2.0}/images/repository-image.png +0 -0
  39. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/__main__.py +0 -0
  40. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/cli/color.py +0 -0
  41. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/cli/config_group.py +0 -0
  42. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/cli/game_group.py +0 -0
  43. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/config/__init__.py +0 -0
  44. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/config/config.json +0 -0
  45. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/everything.py +0 -0
  46. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/extensions/beautiful.py +0 -0
  47. {absfuyu-4.1.0/src/absfuyu/extensions/extra → absfuyu-4.2.0/src/absfuyu/extensions}/data_analysis.py +0 -0
  48. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/fun/WGS.py +0 -0
  49. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/fun/__init__.py +0 -0
  50. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/fun/tarot.py +0 -0
  51. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/game/__init__.py +0 -0
  52. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/game/game_stat.py +0 -0
  53. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/game/sudoku.py +0 -0
  54. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/game/tictactoe.py +0 -0
  55. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/game/wordle.py +0 -0
  56. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/general/__init__.py +0 -0
  57. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/general/content.py +0 -0
  58. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/general/data_extension.py +0 -0
  59. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/general/generator.py +0 -0
  60. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/general/human.py +0 -0
  61. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/logger.py +0 -0
  62. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/pkg_data/chemistry.pkl +0 -0
  63. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/pkg_data/tarot.pkl +0 -0
  64. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/py.typed +0 -0
  65. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/sort.py +0 -0
  66. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/tools/__init__.py +0 -0
  67. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/tools/keygen.py +0 -0
  68. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/tools/obfuscator.py +0 -0
  69. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/tools/stats.py +0 -0
  70. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/tools/web.py +0 -0
  71. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/__init__.py +0 -0
  72. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/api.py +0 -0
  73. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/json_method.py +0 -0
  74. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/lunar.py +0 -0
  75. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/path.py +0 -0
  76. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/performance.py +0 -0
  77. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/pkl.py +0 -0
  78. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/util/zipped.py +0 -0
  79. {absfuyu-4.1.0 → absfuyu-4.2.0}/src/absfuyu/version.py +0 -0
  80. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/__init__.py +0 -0
  81. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/conftest.py +0 -0
  82. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_beautiful.py +0 -0
  83. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_config.py +0 -0
  84. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_data_extension.py +0 -0
  85. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_extensions.py +0 -0
  86. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_fun.py +0 -0
  87. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_game.py +0 -0
  88. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_generator.py +0 -0
  89. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_logger.py +0 -0
  90. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_pkg_data.py +0 -0
  91. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_tarot.py +0 -0
  92. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_tools.py +0 -0
  93. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_util.py +0 -0
  94. {absfuyu-4.1.0 → absfuyu-4.2.0}/tests/test_version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: absfuyu
3
- Version: 4.1.0
3
+ Version: 4.2.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/
@@ -42,30 +42,26 @@ Provides-Extra: extra
42
42
  Requires-Dist: numpy; extra == 'extra'
43
43
  Requires-Dist: pandas; extra == 'extra'
44
44
  Provides-Extra: full
45
- Requires-Dist: absfuyu-res; extra == 'full'
46
45
  Requires-Dist: numpy; extra == 'full'
47
46
  Requires-Dist: pandas; extra == 'full'
48
47
  Requires-Dist: rich; extra == 'full'
49
48
  Requires-Dist: tqdm; extra == 'full'
50
- Provides-Extra: res
51
- Requires-Dist: absfuyu-res; extra == 'res'
52
49
  Description-Content-Type: text/markdown
53
50
 
54
51
  <div align="center">
55
- <h1 align="center">
56
- <img src="https://github.com/AbsoluteWinter/AbsoluteWinter.github.io/blob/main/absfuyu/images/repository-image-crop.png?raw=true" alt="absfuyu"/>
57
- </h1>
58
- <p align="center">
59
- <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/pyversions/absfuyu?style=flat-square&logo=python" alt="PyPI Supported Versions"/></a>
60
- <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/dm/absfuyu?style=flat-square&color=blue" alt="PyPI Downloads"/></a>
61
- <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/v/absfuyu?style=flat-square&logo=pypi" /></a>
62
- <a><img src="https://img.shields.io/pypi/l/absfuyu?style=flat-square&logo=github&color=blue"/></a>
63
- <a><img src="https://img.shields.io/badge/code%20style-black-black?style=flat-square"/></a>
64
- <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square" alt="Ruff" style="max-width:100%;"></a>
65
- </p>
52
+ <h1 align="center">
53
+ <img src="https://github.com/AbsoluteWinter/AbsoluteWinter.github.io/blob/main/absfuyu/images/repository-image-crop.png?raw=true" alt="absfuyu"/>
54
+ </h1>
55
+ <p align="center">
56
+ <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/pyversions/absfuyu?style=flat-square&logo=python" alt="PyPI Supported Versions"/></a>
57
+ <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/dm/absfuyu?style=flat-square&color=blue" alt="PyPI Downloads"/></a>
58
+ <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/v/absfuyu?style=flat-square&logo=pypi" /></a>
59
+ <a><img src="https://img.shields.io/pypi/l/absfuyu?style=flat-square&logo=github&color=blue"/></a>
60
+ <a><img src="https://img.shields.io/badge/code%20style-black-black?style=flat-square"/></a>
61
+ <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square" alt="Ruff" style="max-width:100%;"></a>
62
+ </p>
66
63
  </div>
67
64
 
68
-
69
65
  ---
70
66
 
71
67
  ## **SUMMARY:**
@@ -75,7 +71,7 @@ Description-Content-Type: text/markdown
75
71
  ## **INSTALLATION:**
76
72
 
77
73
  ```bash
78
- $ pip install -U absfuyu
74
+ pip install -U absfuyu
79
75
  ```
80
76
 
81
77
  ## **USAGE:**
@@ -115,7 +111,6 @@ python -m pip install -e .[full,dev]
115
111
  hatch env show
116
112
  ```
117
113
 
118
-
119
114
  ## **LICENSE:**
120
115
 
121
116
  MIT License
@@ -0,0 +1,66 @@
1
+ <div align="center">
2
+ <h1 align="center">
3
+ <img src="https://github.com/AbsoluteWinter/AbsoluteWinter.github.io/blob/main/absfuyu/images/repository-image-crop.png?raw=true" alt="absfuyu"/>
4
+ </h1>
5
+ <p align="center">
6
+ <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/pyversions/absfuyu?style=flat-square&logo=python" alt="PyPI Supported Versions"/></a>
7
+ <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/dm/absfuyu?style=flat-square&color=blue" alt="PyPI Downloads"/></a>
8
+ <a href="https://pypi.org/project/absfuyu/"><img src="https://img.shields.io/pypi/v/absfuyu?style=flat-square&logo=pypi" /></a>
9
+ <a><img src="https://img.shields.io/pypi/l/absfuyu?style=flat-square&logo=github&color=blue"/></a>
10
+ <a><img src="https://img.shields.io/badge/code%20style-black-black?style=flat-square"/></a>
11
+ <a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square" alt="Ruff" style="max-width:100%;"></a>
12
+ </p>
13
+ </div>
14
+
15
+ ---
16
+
17
+ ## **SUMMARY:**
18
+
19
+ *TL;DR: A collection of code*
20
+
21
+ ## **INSTALLATION:**
22
+
23
+ ```bash
24
+ pip install -U absfuyu
25
+ ```
26
+
27
+ ## **USAGE:**
28
+
29
+ ```python
30
+ import absfuyu
31
+ help(absfuyu)
32
+ ```
33
+
34
+ ## **DOCUMENTATION:**
35
+
36
+ > [here](https://absolutewinter.github.io/absfuyu/)
37
+
38
+ ## **DEV SETUP**
39
+
40
+ 1. Create virtual environment
41
+
42
+ ```bash
43
+ python -m venv env
44
+ ```
45
+
46
+ Note: Might need to run this in powershell (windows)
47
+
48
+ ```powershell
49
+ Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
50
+ ```
51
+
52
+ 2. Install required packages
53
+
54
+ ```bash
55
+ python -m pip install -e .[full,dev]
56
+ ```
57
+
58
+ 3. Getting info of dev environment
59
+
60
+ ```bash
61
+ hatch env show
62
+ ```
63
+
64
+ ## **LICENSE:**
65
+
66
+ MIT License
@@ -59,8 +59,7 @@ Repository = "https://github.com/AbsoluteWinter/absfuyu-public"
59
59
  Issues = "https://github.com/AbsoluteWinter/absfuyu-public/issues"
60
60
 
61
61
  [project.optional-dependencies]
62
- res = ["absfuyu-res"]
63
- full = ["absfuyu-res", "numpy", "pandas", "rich", "tqdm"]
62
+ full = ["numpy", "pandas", "rich", "tqdm"]
64
63
  beautiful = ["rich"]
65
64
  extra = ["numpy", "pandas"]
66
65
  dev = ["hatch", "pytest"]
@@ -212,7 +211,6 @@ build = [
212
211
  9617320663a662e77726974656c696e65732863290a7072696e7428224c6963656e7365\
213
212
  207965617220757064617465642229').decode('utf-8'))\"
214
213
  """,
215
- # "python support_scripts/update_license_year.py", # Update license year
216
214
  "hatch clean", # Clean dist/ folder
217
215
  "hatch -v build", # Build package
218
216
  "hatch run docs:build", # Build docs
@@ -310,6 +308,9 @@ ignore = [
310
308
  ]
311
309
  "shorten_number.py" = ["B007"] # Loop control variable not used within loop body
312
310
 
311
+ [tool.ruff.lint.pydocstyle]
312
+ convention = "numpy"
313
+
313
314
  # MARK: TOOL: black
314
315
  [tool.black]
315
316
  line-length = 88
@@ -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__ = "4.1.0"
25
+ __version__ = "4.2.0"
26
26
  __all__ = [
27
27
  "core",
28
28
  "config",
@@ -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)
@@ -3,14 +3,13 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Do
5
5
 
6
- Version: 1.3.0
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
 
@@ -18,7 +17,7 @@ from absfuyu import __title__
18
17
  from absfuyu.cli.color import COLOR
19
18
  from absfuyu.core import __package_feature__
20
19
  from absfuyu.general.human import Human2
21
- from absfuyu.tools.checksum import checksum_operation
20
+ from absfuyu.tools.shutdownizer import ShutDownizer
22
21
  from absfuyu.util.zipped import Zipper
23
22
  from absfuyu.version import PkgVersion
24
23
 
@@ -82,7 +81,11 @@ def fs(date: str, number_string: str) -> None:
82
81
  @click.command(name="info")
83
82
  @click.argument("date", type=str)
84
83
  def info(date: str) -> None:
85
- """Day info"""
84
+ """
85
+ Day info, format: yyyymmdd
86
+
87
+ Remake this
88
+ """
86
89
 
87
90
  instance = Human2(date)
88
91
  print(instance.info())
@@ -98,38 +101,11 @@ def unzip_files_in_dir(dir: str) -> None:
98
101
  print("Done")
99
102
 
100
103
 
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
- "--compare",
114
- "-c",
115
- "hash_to_compare",
116
- type=str,
117
- default=None,
118
- show_default=True,
119
- help="Hash to compare",
120
- )
121
- def file_checksum(
122
- file_path: str,
123
- hash_mode: str | Literal["md5", "sha1", "sha256", "sha512"],
124
- hash_to_compare: str,
125
- ) -> None:
126
- """Checksum for file"""
127
-
128
- res = checksum_operation(file_path, hash_mode=hash_mode)
129
- if hash_to_compare:
130
- print(res == hash_to_compare)
131
- else:
132
- print(res)
104
+ @click.command(name="shutdown")
105
+ def os_shutdown() -> None:
106
+ """Shutdown"""
107
+ engine = ShutDownizer()
108
+ engine.shutdown()
133
109
 
134
110
 
135
111
  @click.group(name="do")
@@ -144,4 +120,4 @@ do_group.add_command(advice)
144
120
  do_group.add_command(fs)
145
121
  do_group.add_command(info)
146
122
  do_group.add_command(unzip_files_in_dir)
147
- do_group.add_command(file_checksum)
123
+ 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: str | Literal["md5", "sha1", "sha256", "sha512"],
63
+ save_result: bool,
64
+ recursive_mode: bool,
65
+ hash_to_compare: str,
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:
72
+ print(res == hash_to_compare)
73
+ else:
74
+ print(res)
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,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Contain type hints and other stuffs
5
5
 
6
- Version: 2.3.0
7
- Date updated: 01/02/2025 (dd/mm/yyyy)
6
+ Version: 2.3.2
7
+ Date updated: 11/02/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -18,14 +18,13 @@ __all__ = [
18
18
  "DATA_PATH",
19
19
  ]
20
20
 
21
- __package_feature__ = ["beautiful", "extra", "res", "full", "dev"]
21
+ __package_feature__ = ["beautiful", "extra", "full", "dev"]
22
22
 
23
23
 
24
24
  # Library
25
25
  ###########################################################################
26
26
  from importlib import import_module
27
27
  from importlib.resources import files
28
- from typing import Iterable
29
28
 
30
29
 
31
30
  class CLITextColor:
@@ -54,5 +53,5 @@ try:
54
53
  tqdm = import_module("tqdm").tqdm
55
54
  except ModuleNotFoundError:
56
55
 
57
- def tqdm(iterable: Iterable, **kwargs):
56
+ def tqdm(iterable, **kwargs):
58
57
  return iterable
@@ -1,6 +1,7 @@
1
1
  """
2
2
  Absfuyu: Extension
3
3
  ------------------
4
+ Features that require additional libraries
4
5
 
5
6
  Version: 1.0.1
6
7
  Date updated: 24/11/2023 (dd/mm/yyyy)
@@ -26,9 +26,9 @@ from absfuyu.logger import logger
26
26
  ###########################################################################
27
27
  _EXTERNAL_DATA = {
28
28
  "chemistry.json": "https://raw.githubusercontent.com/Bowserinator/Periodic-Table-JSON/master/PeriodicTableJSON.json",
29
- "countries.json": "https://github.com/dr5hn/countries-states-cities-database/blob/master/countries.json",
30
29
  "tarot.json": "https://raw.githubusercontent.com/dariusk/corpora/master/data/divination/tarot_interpretations.json",
31
30
  "word_list.json": "https://raw.githubusercontent.com/dwyl/english-words/master/words_dictionary.json",
31
+ # "countries.json": "https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/refs/heads/master/json/countries.json",
32
32
  }
33
33
 
34
34
 
@@ -37,6 +37,7 @@ _EXTERNAL_DATA = {
37
37
  class DataList:
38
38
  CHEMISTRY = files("absfuyu.pkg_data").joinpath("chemistry.pkl")
39
39
  TAROT = files("absfuyu.pkg_data").joinpath("tarot.pkl")
40
+ PASSWORDLIB = files("absfuyu.pkg_data").joinpath("passwordlib_lzma.pkl")
40
41
 
41
42
 
42
43
  class PkgData:
@@ -0,0 +1,154 @@
1
+ """
2
+ Absufyu: Checksum
3
+ -----------------
4
+ Check MD5, SHA256, ...
5
+
6
+ Version: 1.1.1
7
+ Date updated: 05/02/2025 (dd/mm/yyyy)
8
+ """
9
+
10
+ # Module level
11
+ ###########################################################################
12
+ __all__ = ["Checksum", "checksum_operation"]
13
+
14
+
15
+ # Library
16
+ ###########################################################################
17
+ import hashlib
18
+ from pathlib import Path
19
+ from typing import Literal
20
+
21
+ from absfuyu.core import tqdm
22
+
23
+ # Function
24
+ ###########################################################################
25
+
26
+
27
+ # Deprecated
28
+ def checksum_operation(
29
+ file: Path | str,
30
+ hash_mode: str | Literal["md5", "sha1", "sha256", "sha512"] = "sha256",
31
+ ) -> str:
32
+ """This performs checksum"""
33
+ if hash_mode.lower() == "md5":
34
+ hash_engine = hashlib.md5()
35
+ elif hash_mode.lower() == "sha1":
36
+ hash_engine = hashlib.sha1()
37
+ elif hash_mode.lower() == "sha256":
38
+ hash_engine = hashlib.sha256()
39
+ elif hash_mode.lower() == "sha512":
40
+ hash_engine = hashlib.sha512()
41
+ else:
42
+ hash_engine = hashlib.md5()
43
+
44
+ with open(Path(file), "rb") as f:
45
+ while True:
46
+ data = f.read(4096)
47
+ if len(data) == 0:
48
+ break
49
+ else:
50
+ hash_engine.update(data)
51
+ return hash_engine.hexdigest()
52
+
53
+
54
+ class Checksum:
55
+ def __init__(
56
+ self,
57
+ path: str | Path,
58
+ hash_mode: str | Literal["md5", "sha1", "sha256", "sha512"] = "sha256",
59
+ save_result_to_file: bool = False,
60
+ ) -> None:
61
+ """Checksum engine
62
+
63
+ Parameters
64
+ ----------
65
+ path : str | Path
66
+ Path to file/directory to perform checksum
67
+ hash_mode : str | Literal["md5", "sha1", "sha256", "sha512"], optional
68
+ Hash mode, by default "sha256"
69
+ save_result_to_file : bool, optional
70
+ Save checksum result(s) to file, by default False
71
+ """
72
+ self.path = Path(path)
73
+ self.hash_mode = hash_mode
74
+ self.save_result_to_file = save_result_to_file
75
+ self.checksum_result_file_name = "checksum_results.txt"
76
+
77
+ def _get_hash_engine(self):
78
+ hash_mode = self.hash_mode
79
+ if hash_mode.lower() == "md5":
80
+ hash_engine = hashlib.md5()
81
+ elif hash_mode.lower() == "sha1":
82
+ hash_engine = hashlib.sha1()
83
+ elif hash_mode.lower() == "sha256":
84
+ hash_engine = hashlib.sha256()
85
+ elif hash_mode.lower() == "sha512":
86
+ hash_engine = hashlib.sha512()
87
+ else:
88
+ hash_engine = hashlib.md5()
89
+ return hash_engine
90
+
91
+ def _checksum_operation(
92
+ self,
93
+ file: Path | str,
94
+ ) -> str:
95
+ """This performs checksum"""
96
+
97
+ hash_engine = self._get_hash_engine().copy()
98
+ with open(Path(file), "rb") as f:
99
+ # Read and hash the file in 4K chunks. Reading the whole
100
+ # file at once might consume a lot of memory if it is
101
+ # large.
102
+ while True:
103
+ data = f.read(4096)
104
+ if len(data) == 0:
105
+ break
106
+ else:
107
+ hash_engine.update(data)
108
+ return hash_engine.hexdigest() # type: ignore
109
+
110
+ def checksum(self, recursive: bool = True) -> str:
111
+ """Perform checksum
112
+
113
+ Parameters
114
+ ----------
115
+ recursive : bool, optional
116
+ Do checksum for every file in the folder (including child folder), by default True
117
+
118
+ Returns
119
+ -------
120
+ str
121
+ Checksum hash
122
+ """
123
+ if self.path.absolute().is_dir(): # Dir
124
+ new_path = self.path.joinpath(self.checksum_result_file_name)
125
+ # List of files
126
+ if recursive:
127
+ file_list: list[Path] = [
128
+ x for x in self.path.glob("**/*") if x.is_file()
129
+ ]
130
+ else:
131
+ file_list = [x for x in self.path.glob("*") if x.is_file()]
132
+
133
+ # Checksum
134
+ res = []
135
+ for x in tqdm(file_list, desc="Calculating hash", unit_scale=True):
136
+ name = x.relative_to(self.path)
137
+ res.append(f"{self._checksum_operation(x)} | {name}")
138
+ output = "\n".join(res)
139
+ else: # File
140
+ new_path = self.path.with_name(self.checksum_result_file_name)
141
+ output = self._checksum_operation(self.path)
142
+
143
+ # Save result
144
+ if self.save_result_to_file:
145
+ with open(new_path, "w", encoding="utf-8") as f:
146
+ f.write(output)
147
+
148
+ return output
149
+
150
+
151
+ # Run
152
+ ###########################################################################
153
+ if __name__ == "__main__":
154
+ pass