absfuyu 3.0.0__py3-none-any.whl → 3.1.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/config/config.json +1 -1
- absfuyu/extensions/dev/__init__.py +142 -2
- absfuyu/extensions/extra/data_analysis.py +687 -119
- absfuyu/fun/tarot.py +9 -7
- absfuyu/game/tictactoe2.py +90 -78
- absfuyu/general/data_extension.py +147 -11
- absfuyu/general/generator.py +65 -4
- absfuyu/general/human.py +27 -2
- absfuyu/util/performance.py +101 -14
- {absfuyu-3.0.0.dist-info → absfuyu-3.1.0.dist-info}/METADATA +23 -23
- {absfuyu-3.0.0.dist-info → absfuyu-3.1.0.dist-info}/RECORD +15 -15
- {absfuyu-3.0.0.dist-info → absfuyu-3.1.0.dist-info}/LICENSE +0 -0
- {absfuyu-3.0.0.dist-info → absfuyu-3.1.0.dist-info}/WHEEL +0 -0
- {absfuyu-3.0.0.dist-info → absfuyu-3.1.0.dist-info}/entry_points.txt +0 -0
- {absfuyu-3.0.0.dist-info → absfuyu-3.1.0.dist-info}/top_level.txt +0 -0
absfuyu/config/config.json
CHANGED
|
@@ -18,9 +18,11 @@ __all__ = [
|
|
|
18
18
|
|
|
19
19
|
# Library
|
|
20
20
|
###########################################################################
|
|
21
|
-
import
|
|
22
|
-
|
|
21
|
+
import base64
|
|
22
|
+
from collections import deque
|
|
23
23
|
from functools import lru_cache
|
|
24
|
+
import re
|
|
25
|
+
from typing import Dict, TypedDict, Final, List, NamedTuple
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
# PASSWORD CHECKER
|
|
@@ -99,3 +101,141 @@ def optional_import(module: str, name: str = None, package: str = None):
|
|
|
99
101
|
raise ValueError(msg) from import_error
|
|
100
102
|
|
|
101
103
|
return _failed_import
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def load_toml_file(toml_file: str):
|
|
107
|
+
"""
|
|
108
|
+
Load ``.toml`` file
|
|
109
|
+
|
|
110
|
+
:param toml_file: Path to ``.toml`` file
|
|
111
|
+
"""
|
|
112
|
+
from sys import version_info as _python_version
|
|
113
|
+
|
|
114
|
+
if _python_version.minor < 11:
|
|
115
|
+
try:
|
|
116
|
+
import tomli as tomllib
|
|
117
|
+
except ImportError:
|
|
118
|
+
raise ImportError("Please install tomli python package")
|
|
119
|
+
except:
|
|
120
|
+
raise SystemExit
|
|
121
|
+
else:
|
|
122
|
+
import tomllib
|
|
123
|
+
|
|
124
|
+
with open(toml_file, "rb") as file:
|
|
125
|
+
toml_data = tomllib.load(file)
|
|
126
|
+
return toml_data
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def get_sitemap(url: str):
|
|
130
|
+
import re
|
|
131
|
+
import requests
|
|
132
|
+
|
|
133
|
+
class Url(NamedTuple):
|
|
134
|
+
base: str
|
|
135
|
+
extra: str
|
|
136
|
+
|
|
137
|
+
def __str__(self) -> str:
|
|
138
|
+
return f"{self.base}{self.extra}"
|
|
139
|
+
|
|
140
|
+
def __repr__(self) -> str:
|
|
141
|
+
return f"{self.__class__.__name__}({self.base}{self.extra})"
|
|
142
|
+
|
|
143
|
+
# robots.txt
|
|
144
|
+
# sitemap.xml
|
|
145
|
+
if not url.endswith("/"):
|
|
146
|
+
url += "/"
|
|
147
|
+
pattern = re.compile(
|
|
148
|
+
r"([(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b)([-a-zA-Z0-9@:%_\+.~#?&//=]*)",
|
|
149
|
+
re.IGNORECASE,
|
|
150
|
+
)
|
|
151
|
+
try:
|
|
152
|
+
url += "sitemap.xml"
|
|
153
|
+
res = requests.get(url).text
|
|
154
|
+
except:
|
|
155
|
+
# W.I.P
|
|
156
|
+
url += "robots.txt"
|
|
157
|
+
res = requests.get(url).text
|
|
158
|
+
regex = re.findall(pattern, res)
|
|
159
|
+
return list(map(Url._make, regex))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
from absfuyu.general import ClassBase
|
|
163
|
+
|
|
164
|
+
class SimpleStrEncrypt(ClassBase):
|
|
165
|
+
"""
|
|
166
|
+
Simple Encryption
|
|
167
|
+
|
|
168
|
+
Logic:
|
|
169
|
+
- Base64
|
|
170
|
+
- Shift characters
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
def __init__(self, times_to_base64_encode: int = 10, shift: int = 13) -> None:
|
|
174
|
+
"""
|
|
175
|
+
:param times_to_base64_encode: How many time to base64 encode
|
|
176
|
+
:type times_to_base64_encode: int
|
|
177
|
+
:param shift: Shift characters to the right for how many position
|
|
178
|
+
:type shift: int
|
|
179
|
+
"""
|
|
180
|
+
self.times_to_base64_encode = times_to_base64_encode
|
|
181
|
+
self.shift = shift
|
|
182
|
+
|
|
183
|
+
# Support
|
|
184
|
+
def _convert_table(self, text: str, shift: int) -> Dict[str, str]:
|
|
185
|
+
data = text
|
|
186
|
+
|
|
187
|
+
data = deque(sorted(list(set(data))))
|
|
188
|
+
translate = data.copy()
|
|
189
|
+
translate.rotate(shift)
|
|
190
|
+
convert_table = dict(zip(data, translate))
|
|
191
|
+
|
|
192
|
+
return convert_table
|
|
193
|
+
|
|
194
|
+
@staticmethod
|
|
195
|
+
def _use_convert_table(text: str, convert_table: Dict[str, str]) -> str:
|
|
196
|
+
"""Use convert table"""
|
|
197
|
+
data = list(text)
|
|
198
|
+
for i, x in enumerate(data):
|
|
199
|
+
data[i] = convert_table[x]
|
|
200
|
+
return "".join(data)
|
|
201
|
+
|
|
202
|
+
@staticmethod
|
|
203
|
+
def _b64encode(text: str) -> str:
|
|
204
|
+
return base64.b64encode(text.encode()).decode()
|
|
205
|
+
|
|
206
|
+
@staticmethod
|
|
207
|
+
def _b64decode(text: str) -> str:
|
|
208
|
+
return base64.b64decode(text).decode()
|
|
209
|
+
|
|
210
|
+
# Main
|
|
211
|
+
def encode(self, text: str) -> str:
|
|
212
|
+
# Base64
|
|
213
|
+
data = text
|
|
214
|
+
for _ in range(self.times_to_base64_encode):
|
|
215
|
+
data = self._b64encode(data)
|
|
216
|
+
|
|
217
|
+
# Shift
|
|
218
|
+
convert_table = self._convert_table(data, self.shift)
|
|
219
|
+
return self._use_convert_table(data, convert_table)
|
|
220
|
+
|
|
221
|
+
def decode(self, text: str) -> str:
|
|
222
|
+
# Shift back
|
|
223
|
+
data = text
|
|
224
|
+
convert_table = self._convert_table(data, -self.shift)
|
|
225
|
+
data = self._use_convert_table(data, convert_table)
|
|
226
|
+
|
|
227
|
+
# Base64
|
|
228
|
+
for _ in range(self.times_to_base64_encode):
|
|
229
|
+
data = self._b64decode(data)
|
|
230
|
+
|
|
231
|
+
return data
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
# testing
|
|
237
|
+
CON_VAR: Final[List[str]] = ["a", "b"] # Declare as final
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
if __name__ == "__main__":
|
|
241
|
+
print(get_sitemap("https://kingdomality.com/"))
|