absfuyu 5.8.0__py3-none-any.whl → 5.9.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 (79) hide show
  1. absfuyu/__init__.py +1 -1
  2. absfuyu/__main__.py +2 -2
  3. absfuyu/cli/__init__.py +2 -2
  4. absfuyu/cli/color.py +2 -2
  5. absfuyu/cli/config_group.py +2 -2
  6. absfuyu/cli/do_group.py +2 -2
  7. absfuyu/cli/game_group.py +2 -2
  8. absfuyu/cli/tool_group.py +2 -2
  9. absfuyu/config/__init__.py +2 -2
  10. absfuyu/core/__init__.py +2 -2
  11. absfuyu/core/baseclass.py +2 -2
  12. absfuyu/core/baseclass2.py +2 -2
  13. absfuyu/core/decorator.py +2 -2
  14. absfuyu/core/docstring.py +2 -2
  15. absfuyu/core/dummy_cli.py +2 -2
  16. absfuyu/core/dummy_func.py +2 -2
  17. absfuyu/dxt/__init__.py +2 -2
  18. absfuyu/dxt/dictext.py +2 -2
  19. absfuyu/dxt/dxt_support.py +2 -2
  20. absfuyu/dxt/intext.py +2 -2
  21. absfuyu/dxt/listext.py +2 -2
  22. absfuyu/dxt/strext.py +2 -2
  23. absfuyu/extra/__init__.py +2 -2
  24. absfuyu/extra/beautiful.py +2 -2
  25. absfuyu/extra/da/__init__.py +37 -3
  26. absfuyu/extra/da/dadf.py +2 -2
  27. absfuyu/extra/da/dadf_base.py +2 -2
  28. absfuyu/extra/da/df_func.py +2 -2
  29. absfuyu/extra/da/mplt.py +2 -2
  30. absfuyu/extra/data_analysis.py +2 -2
  31. absfuyu/extra/pdf.py +2 -2
  32. absfuyu/extra/rclone.py +253 -0
  33. absfuyu/extra/xml.py +2 -2
  34. absfuyu/fun/__init__.py +2 -2
  35. absfuyu/fun/rubik.py +2 -2
  36. absfuyu/fun/tarot.py +2 -2
  37. absfuyu/game/__init__.py +2 -2
  38. absfuyu/game/game_stat.py +2 -2
  39. absfuyu/game/sudoku.py +2 -2
  40. absfuyu/game/tictactoe.py +2 -2
  41. absfuyu/game/wordle.py +2 -2
  42. absfuyu/general/__init__.py +2 -2
  43. absfuyu/general/content.py +2 -2
  44. absfuyu/general/human.py +2 -2
  45. absfuyu/general/shape.py +2 -2
  46. absfuyu/logger.py +2 -2
  47. absfuyu/pkg_data/__init__.py +2 -2
  48. absfuyu/pkg_data/deprecated.py +2 -2
  49. absfuyu/pkg_data/logo.py +2 -2
  50. absfuyu/sort.py +2 -2
  51. absfuyu/tools/__init__.py +2 -2
  52. absfuyu/tools/checksum.py +2 -2
  53. absfuyu/tools/converter.py +2 -2
  54. absfuyu/tools/generator.py +2 -2
  55. absfuyu/tools/inspector.py +2 -2
  56. absfuyu/tools/keygen.py +2 -2
  57. absfuyu/tools/obfuscator.py +2 -2
  58. absfuyu/tools/passwordlib.py +2 -2
  59. absfuyu/tools/shutdownizer.py +2 -2
  60. absfuyu/tools/sw.py +76 -5
  61. absfuyu/tools/web.py +2 -2
  62. absfuyu/typings.py +2 -2
  63. absfuyu/util/__init__.py +31 -2
  64. absfuyu/util/api.py +2 -2
  65. absfuyu/util/gui.py +32 -0
  66. absfuyu/util/json_method.py +2 -2
  67. absfuyu/util/lunar.py +2 -2
  68. absfuyu/util/path.py +2 -2
  69. absfuyu/util/performance.py +2 -2
  70. absfuyu/util/shorten_number.py +2 -2
  71. absfuyu/util/text_table.py +2 -2
  72. absfuyu/util/zipped.py +2 -2
  73. absfuyu/version.py +2 -2
  74. {absfuyu-5.8.0.dist-info → absfuyu-5.9.0.dist-info}/METADATA +4 -1
  75. absfuyu-5.9.0.dist-info/RECORD +83 -0
  76. absfuyu-5.8.0.dist-info/RECORD +0 -81
  77. {absfuyu-5.8.0.dist-info → absfuyu-5.9.0.dist-info}/WHEEL +0 -0
  78. {absfuyu-5.8.0.dist-info → absfuyu-5.9.0.dist-info}/entry_points.txt +0 -0
  79. {absfuyu-5.8.0.dist-info → absfuyu-5.9.0.dist-info}/licenses/LICENSE +0 -0
absfuyu/__init__.py CHANGED
@@ -22,7 +22,7 @@ Using in cmd:
22
22
  __title__ = "absfuyu"
23
23
  __author__ = "AbsoluteWinter"
24
24
  __license__ = "MIT License"
25
- __version__ = "5.8.0"
25
+ __version__ = "5.9.0"
26
26
  __all__ = [
27
27
  "core",
28
28
  "config",
absfuyu/__main__.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU
3
3
  -------
4
4
  COMMAND LINE INTERFACE
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Library
absfuyu/cli/__init__.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU
3
3
  -------
4
4
  COMMAND LINE INTERFACE
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  __all__ = ["cli"]
absfuyu/cli/color.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Color
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Config
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/cli/do_group.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Do
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/cli/game_group.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Game
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/cli/tool_group.py CHANGED
@@ -3,8 +3,8 @@ ABSFUYU CLI
3
3
  -----------
4
4
  Tool
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -3,8 +3,8 @@ Absfuyu: Configuration
3
3
  ----------------------
4
4
  Package configuration module
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
absfuyu/core/__init__.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Bases for other features
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/core/baseclass.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Bases for other features
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Bases for other features (with library)
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/core/decorator.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Decorator
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/core/docstring.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Sphinx docstring decorator
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/core/dummy_cli.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Dummy cli
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -3,8 +3,8 @@ Absfuyu: Core
3
3
  -------------
4
4
  Dummy functions when other libraries are unvailable
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/dxt/__init__.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  Extension for data type such as ``list``, ``str``, ``dict``, ...
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
 
9
9
  Features:
10
10
  ---------
absfuyu/dxt/dictext.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  dict extension
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  Support classes
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/dxt/intext.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  int extension
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/dxt/listext.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  list extension
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/dxt/strext.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Extension
3
3
  -----------------------
4
4
  str extension
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 19/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module Package
absfuyu/extra/__init__.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Extra
3
3
  --------------
4
4
  Features that require additional libraries
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
 
@@ -3,8 +3,8 @@ Absfuyu: Beautiful
3
3
  ------------------
4
4
  A decorator that makes output more beautiful
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
@@ -3,13 +3,19 @@ Absfuyu: Data Analysis
3
3
  ----------------------
4
4
  Data Analyst
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
11
11
  # ---------------------------------------------------------------------------
12
- __all__ = ["MatplotlibFormatString", "DADF"]
12
+ __all__ = [
13
+ "MatplotlibFormatString",
14
+ "DADF",
15
+ # Function
16
+ "custom_pandas_settings",
17
+ "reset_custom_pandas_settings",
18
+ ]
13
19
 
14
20
 
15
21
  # Library
@@ -36,3 +42,31 @@ else:
36
42
 
37
43
  from absfuyu.extra.da.dadf import DADF
38
44
  from absfuyu.extra.da.mplt import MatplotlibFormatString
45
+
46
+
47
+ # Function
48
+ # ---------------------------------------------------------------------------
49
+ def custom_pandas_settings(*, show_all_rows: bool = False) -> None:
50
+ """
51
+ Custom pandas settings. Currently only show all cols/rows
52
+
53
+ Parameters
54
+ ----------
55
+ show_all_rows : bool, optional
56
+ Show all rows, by default False
57
+ """
58
+ # Shows all columns
59
+ pd.set_option("display.max_columns", None) # type: ignore
60
+
61
+ if show_all_rows:
62
+ # (optional) also show all rows if needed
63
+ pd.set_option("display.max_rows", None) # type: ignore
64
+
65
+
66
+ def reset_custom_pandas_settings() -> None:
67
+ """
68
+ Reset custom pandas settings
69
+ """
70
+ settings = ["display.max_columns", "display.max_rows"]
71
+ for x in settings:
72
+ pd.reset_option(x) # type: ignore
absfuyu/extra/da/dadf.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Analysis
3
3
  ----------------------
4
4
  Data Analyst DataFrame
5
5
 
6
- Version: 5.8.0
7
- Date updated: 17/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
@@ -3,8 +3,8 @@ Absfuyu: Data Analysis
3
3
  ----------------------
4
4
  Data Analyst DataFrame - Base/Core
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
@@ -3,8 +3,8 @@ Absfuyu: Data Analysis
3
3
  ----------------------
4
4
  DF Function
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
absfuyu/extra/da/mplt.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: Data Analysis
3
3
  ----------------------
4
4
  Matplotlib Helper
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
@@ -4,8 +4,8 @@ Absfuyu: Data Analysis [W.I.P]
4
4
  Extension for ``pd.DataFrame``
5
5
  (deprecated)
6
6
 
7
- Version: 5.8.0
8
- Date updated: 16/09/2025 (dd/mm/yyyy)
7
+ Version: 5.9.0
8
+ Date updated: 23/09/2025 (dd/mm/yyyy)
9
9
  """
10
10
 
11
11
  # Library
absfuyu/extra/pdf.py CHANGED
@@ -3,8 +3,8 @@ Absfuyu: PDF
3
3
  ------------
4
4
  PDF Tool [W.I.P]
5
5
 
6
- Version: 5.8.0
7
- Date updated: 16/09/2025 (dd/mm/yyyy)
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
8
  """
9
9
 
10
10
  # Module level
@@ -0,0 +1,253 @@
1
+ """
2
+ Absfuyu: Rclone decrypt
3
+ -----------------------
4
+ Rclone decryptor
5
+
6
+ Version: 5.9.0
7
+ Date updated: 23/09/2025 (dd/mm/yyyy)
8
+ """
9
+
10
+ # Module level
11
+ # ---------------------------------------------------------------------------
12
+ __all__ = ["RcloneEncryptDecrypt", "DirectoryRcloneDEMixin"]
13
+
14
+
15
+ # Library
16
+ # ---------------------------------------------------------------------------
17
+ import os
18
+ import shutil
19
+ from pathlib import Path
20
+ from typing import Literal, Self
21
+
22
+ from rclone import Crypt
23
+
24
+ from absfuyu.core.baseclass import AutoREPRMixin
25
+ from absfuyu.logger import LogLevel, logger
26
+ from absfuyu.util.path import DirectoryBase
27
+
28
+
29
+ # Class
30
+ # ---------------------------------------------------------------------------
31
+ class RcloneEncryptDecrypt(AutoREPRMixin):
32
+ """
33
+ Rclone Decrypt/Encrypt Module
34
+ """
35
+
36
+ def __init__(self, crypt: Crypt) -> None:
37
+ """
38
+ This will encrypt/decrypt with rclone style
39
+
40
+ Parameters
41
+ ----------
42
+ crypt : Crypt
43
+ ``rclone.Crypt`` object | Encrypt/Decrypt engine
44
+ """
45
+ self._crypt = crypt
46
+
47
+ @classmethod
48
+ def from_passwd_salt(cls, passwd: str, salt: str | None = None) -> Self:
49
+ """
50
+ Create Rclone Decrypt/Encrypt object from password and salt
51
+
52
+ Parameters
53
+ ----------
54
+ passwd : str
55
+ Custom password
56
+
57
+ salt : str | None, optional
58
+ Custom salt, by default None
59
+
60
+ Returns
61
+ -------
62
+ Self
63
+ Rclone Decrypt/Encrypt object
64
+ """
65
+ if salt is None:
66
+ crypt: Crypt = Crypt(passwd=passwd)
67
+ else:
68
+ crypt: Crypt = Crypt(passwd=passwd, salt=salt)
69
+ return cls(crypt)
70
+
71
+ # Support
72
+ @staticmethod
73
+ def _directory_validator(path: Path) -> Path:
74
+ """Validate if directory exists, then return the path"""
75
+ path = Path(path)
76
+ if not path.exists():
77
+ raise ValueError("Path does not exist")
78
+ return path
79
+
80
+ def _modify_name(self, name_to_modify: str, mode: Literal["encrypt", "decrypt"]) -> str:
81
+ if mode == "decrypt":
82
+ return self._crypt.Name.standard_decrypt(name_to_modify)
83
+ if mode == "encrypt":
84
+ return self._crypt.Name.standard_encrypt(name_to_modify)
85
+
86
+ def _decrypt_encrypt_operation(
87
+ self,
88
+ mode: Literal["encrypt", "decrypt"],
89
+ root_dir: Path | str, # type: ignore
90
+ delete_when_complete: bool = False,
91
+ ) -> None:
92
+ """
93
+ Base operation to decrypt, encrypt
94
+
95
+ Parameters
96
+ ----------
97
+ mode : Literal["encrypt", "decrypt"]
98
+ Encrypt or decrypt
99
+
100
+ root_dir : Path | str
101
+ Directory location
102
+
103
+ delete_when_complete : bool
104
+ Delete directory when completed, defaults to False
105
+ """
106
+
107
+ logger.info(f"Begin operation: {mode.title()}")
108
+ root_dir = Path(root_dir)
109
+ FILE_MODE = False
110
+
111
+ # Make Base folder
112
+ if root_dir.is_file():
113
+ # Get name of parent dir and make name
114
+ temp = self._modify_name(root_dir.parent.name, "encrypt" if mode == "decrypt" else "decrypt")
115
+ # Create sub dir
116
+ base_dir = root_dir.parent.joinpath(temp)
117
+ base_dir.mkdir(exist_ok=True, parents=True)
118
+ # Move file to that dir
119
+ new_path = root_dir.rename(base_dir.joinpath(root_dir.name))
120
+ root_dir = base_dir # Make root dir
121
+ FILE_MODE = True
122
+ else:
123
+ root_dir: Path = self._directory_validator(root_dir)
124
+ base_name: str = self._modify_name(root_dir.name, mode=mode)
125
+ base_dir: Path = root_dir.parent.joinpath(base_name)
126
+ base_dir.mkdir(exist_ok=True, parents=True)
127
+
128
+ _ljust: int = 17 # Logger ljust value
129
+
130
+ # Decrypt / Encrypt
131
+ for path in root_dir.glob("**/*"):
132
+ rel_path: Path = path.relative_to(root_dir)
133
+ rel_path_splited: list[str] = str(rel_path).split(os.sep)
134
+ rel_path_modified: list[str] = [self._modify_name(x, mode=mode) for x in rel_path_splited]
135
+ new_path: Path = base_dir.joinpath(*rel_path_modified)
136
+
137
+ if path.is_dir():
138
+ logger.debug(f"{mode.title()}ing Dir:".ljust(_ljust) + f"{path}")
139
+ new_path.mkdir(exist_ok=True, parents=True)
140
+ logger.debug(f"{mode.title()}ed Dir:".ljust(_ljust) + f"{new_path}")
141
+ else:
142
+ logger.debug(f"{mode.title()}ing File:".ljust(_ljust) + f"{path}")
143
+ if mode == "decrypt":
144
+ self._crypt.File.file_decrypt(path, new_path) # type: ignore
145
+ if mode == "encrypt":
146
+ self._crypt.File.file_encrypt(path, new_path) # type: ignore
147
+ logger.debug(f"{mode.title()}ed File:".ljust(_ljust) + f"{new_path}")
148
+ logger.info(f"Operation: {mode.title()} COMPLETED")
149
+
150
+ # File mode
151
+ if FILE_MODE:
152
+ new_path.rename(root_dir.parent.joinpath(new_path.name)) # type: ignore
153
+ shutil.rmtree(root_dir)
154
+
155
+ # Delete when completed
156
+ if delete_when_complete:
157
+ logger.debug(f"Deleting {root_dir}")
158
+ shutil.rmtree(root_dir)
159
+ logger.debug(f"Deleting {root_dir}...DONE")
160
+
161
+ # Decrypt/Encrypt
162
+ def decrypt(self, root_dir: Path, delete_when_complete: bool = False) -> None:
163
+ """
164
+ Decrypt encrypted directory.
165
+
166
+ This will decrypt the directory itself and
167
+ create a decrypted directory next to the original
168
+
169
+ Parameters
170
+ ----------
171
+ root_dir : Path
172
+ Directory location
173
+
174
+ delete_when_complete : bool, optional
175
+ Delete directory when completed, by default False
176
+ """
177
+ self._decrypt_encrypt_operation(mode="decrypt", root_dir=root_dir, delete_when_complete=delete_when_complete)
178
+
179
+ def encrypt(self, root_dir: Path, delete_when_complete: bool = False) -> None:
180
+ """
181
+ Encrypt entire directory.
182
+
183
+ This will encrypt the directory itself and
184
+ create an encrypted directory next to the original
185
+
186
+ Parameters
187
+ ----------
188
+ root_dir : Path
189
+ Directory location
190
+
191
+ delete_when_complete : bool, optional
192
+ Delete directory when completed, by default False
193
+ """
194
+ self._decrypt_encrypt_operation(mode="encrypt", root_dir=root_dir, delete_when_complete=delete_when_complete)
195
+
196
+
197
+ class DirectoryRcloneDEMixin(DirectoryBase):
198
+ """
199
+ Directory - Rclone encrypt/decrypt
200
+
201
+ Extension for ``absfuyu.util.path.Directory``
202
+
203
+ - Decrypt
204
+ - Encrypt
205
+ """
206
+
207
+ def rclone_encrypt(self, passwd: str, salt: str | None = None, delete_when_complete: bool = False) -> None:
208
+ """
209
+ Encrypt entire directory.
210
+
211
+ This will encrypt the directory itself and
212
+ create an encrypted directory next to the original
213
+
214
+ Parameters
215
+ ----------
216
+ passwd : str
217
+ Custom password
218
+
219
+ salt : str | None, optional
220
+ Custom salt, by default None
221
+
222
+ delete_when_complete : bool, optional
223
+ Delete directory when completed, by default False
224
+ """
225
+ engine = RcloneEncryptDecrypt.from_passwd_salt(passwd=passwd, salt=salt)
226
+ engine.encrypt(self.source_path, delete_when_complete=delete_when_complete)
227
+
228
+ def rclone_decrypt(self, passwd: str, salt: str | None = None, delete_when_complete: bool = False) -> None:
229
+ """
230
+ Decrypt encrypted directory.
231
+
232
+ This will decrypt the directory itself and
233
+ create a decrypted directory next to the original
234
+
235
+ Parameters
236
+ ----------
237
+ passwd : str
238
+ Custom password
239
+
240
+ salt : str | None, optional
241
+ Custom salt, by default None
242
+
243
+ delete_when_complete : bool, optional
244
+ Delete directory when completed, by default False
245
+ """
246
+ engine = RcloneEncryptDecrypt.from_passwd_salt(passwd=passwd, salt=salt)
247
+ engine.decrypt(self.source_path, delete_when_complete=delete_when_complete)
248
+
249
+
250
+ # Run
251
+ # -----------------------------------------------------------------------------------------------
252
+ if __name__ == "__main__":
253
+ logger.setLevel(LogLevel.DEBUG)