KL-Py 0.0.1__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.
- KL_Py/KL_Py.py +4400 -0
- KL_Py/__init__.py +1 -0
- KL_Py/hindGui/__init__.py +16529 -0
- KL_Py/hindGui/_utils.py +140 -0
- KL_Py/hindGui/elements/base.py +1055 -0
- KL_Py/hindGui/elements/button.py +947 -0
- KL_Py/hindGui/elements/calendar.py +222 -0
- KL_Py/hindGui/elements/canvas.py +122 -0
- KL_Py/hindGui/elements/center.py +44 -0
- KL_Py/hindGui/elements/checkbox.py +240 -0
- KL_Py/hindGui/elements/column.py +443 -0
- KL_Py/hindGui/elements/combo.py +329 -0
- KL_Py/hindGui/elements/error.py +47 -0
- KL_Py/hindGui/elements/frame.py +273 -0
- KL_Py/hindGui/elements/graph.py +817 -0
- KL_Py/hindGui/elements/helpers.py +202 -0
- KL_Py/hindGui/elements/image.py +324 -0
- KL_Py/hindGui/elements/input.py +310 -0
- KL_Py/hindGui/elements/list_box.py +392 -0
- KL_Py/hindGui/elements/menu.py +192 -0
- KL_Py/hindGui/elements/multiline.py +685 -0
- KL_Py/hindGui/elements/option_menu.py +168 -0
- KL_Py/hindGui/elements/pane.py +127 -0
- KL_Py/hindGui/elements/progress_bar.py +304 -0
- KL_Py/hindGui/elements/radio.py +252 -0
- KL_Py/hindGui/elements/separator.py +64 -0
- KL_Py/hindGui/elements/sizegrip.py +34 -0
- KL_Py/hindGui/elements/slider.py +199 -0
- KL_Py/hindGui/elements/spin.py +252 -0
- KL_Py/hindGui/elements/status_bar.py +165 -0
- KL_Py/hindGui/elements/stretch.py +26 -0
- KL_Py/hindGui/elements/tab.py +697 -0
- KL_Py/hindGui/elements/table.py +463 -0
- KL_Py/hindGui/elements/text.py +413 -0
- KL_Py/hindGui/elements/tree.py +493 -0
- KL_Py/hindGui/replace.py +45 -0
- KL_Py/hindGui/tray.py +358 -0
- KL_Py/hindGui/window.py +2906 -0
- KL_Py/requests/__init__.py +184 -0
- KL_Py/requests/__version__.py +14 -0
- KL_Py/requests/_internal_utils.py +50 -0
- KL_Py/requests/adapters.py +719 -0
- KL_Py/requests/api.py +157 -0
- KL_Py/requests/auth.py +314 -0
- KL_Py/requests/certifi/__init__.py +4 -0
- KL_Py/requests/certifi/__main__.py +12 -0
- KL_Py/requests/certifi/core.py +83 -0
- KL_Py/requests/certifi/py.typed +0 -0
- KL_Py/requests/certs.py +17 -0
- KL_Py/requests/charset_normalizer/__init__.py +48 -0
- KL_Py/requests/charset_normalizer/__main__.py +6 -0
- KL_Py/requests/charset_normalizer/api.py +671 -0
- KL_Py/requests/charset_normalizer/cd.py +421 -0
- KL_Py/requests/charset_normalizer/cli/__init__.py +8 -0
- KL_Py/requests/charset_normalizer/cli/__main__.py +363 -0
- KL_Py/requests/charset_normalizer/constant.py +2031 -0
- KL_Py/requests/charset_normalizer/legacy.py +80 -0
- KL_Py/requests/charset_normalizer/md.py +744 -0
- KL_Py/requests/charset_normalizer/models.py +359 -0
- KL_Py/requests/charset_normalizer/py.typed +0 -0
- KL_Py/requests/charset_normalizer/utils.py +420 -0
- KL_Py/requests/charset_normalizer/version.py +8 -0
- KL_Py/requests/compat.py +106 -0
- KL_Py/requests/cookies.py +561 -0
- KL_Py/requests/exceptions.py +151 -0
- KL_Py/requests/help.py +134 -0
- KL_Py/requests/hooks.py +33 -0
- KL_Py/requests/idna/__init__.py +45 -0
- KL_Py/requests/idna/codec.py +122 -0
- KL_Py/requests/idna/compat.py +15 -0
- KL_Py/requests/idna/core.py +437 -0
- KL_Py/requests/idna/idnadata.py +4309 -0
- KL_Py/requests/idna/intranges.py +57 -0
- KL_Py/requests/idna/package_data.py +1 -0
- KL_Py/requests/idna/py.typed +0 -0
- KL_Py/requests/idna/uts46data.py +8841 -0
- KL_Py/requests/models.py +1039 -0
- KL_Py/requests/packages.py +23 -0
- KL_Py/requests/sessions.py +831 -0
- KL_Py/requests/status_codes.py +128 -0
- KL_Py/requests/structures.py +99 -0
- KL_Py/requests/urllib3/__init__.py +211 -0
- KL_Py/requests/urllib3/_base_connection.py +165 -0
- KL_Py/requests/urllib3/_collections.py +487 -0
- KL_Py/requests/urllib3/_request_methods.py +278 -0
- KL_Py/requests/urllib3/_version.py +34 -0
- KL_Py/requests/urllib3/connection.py +1099 -0
- KL_Py/requests/urllib3/connectionpool.py +1178 -0
- KL_Py/requests/urllib3/contrib/__init__.py +0 -0
- KL_Py/requests/urllib3/contrib/emscripten/__init__.py +17 -0
- KL_Py/requests/urllib3/contrib/emscripten/connection.py +260 -0
- KL_Py/requests/urllib3/contrib/emscripten/fetch.py +726 -0
- KL_Py/requests/urllib3/contrib/emscripten/request.py +22 -0
- KL_Py/requests/urllib3/contrib/emscripten/response.py +277 -0
- KL_Py/requests/urllib3/contrib/pyopenssl.py +564 -0
- KL_Py/requests/urllib3/contrib/socks.py +228 -0
- KL_Py/requests/urllib3/exceptions.py +335 -0
- KL_Py/requests/urllib3/fields.py +341 -0
- KL_Py/requests/urllib3/filepost.py +89 -0
- KL_Py/requests/urllib3/http2/__init__.py +53 -0
- KL_Py/requests/urllib3/http2/connection.py +356 -0
- KL_Py/requests/urllib3/http2/probe.py +87 -0
- KL_Py/requests/urllib3/poolmanager.py +651 -0
- KL_Py/requests/urllib3/py.typed +2 -0
- KL_Py/requests/urllib3/response.py +1480 -0
- KL_Py/requests/urllib3/util/__init__.py +42 -0
- KL_Py/requests/urllib3/util/connection.py +137 -0
- KL_Py/requests/urllib3/util/proxy.py +43 -0
- KL_Py/requests/urllib3/util/request.py +263 -0
- KL_Py/requests/urllib3/util/response.py +101 -0
- KL_Py/requests/urllib3/util/retry.py +549 -0
- KL_Py/requests/urllib3/util/ssl_.py +527 -0
- KL_Py/requests/urllib3/util/ssl_match_hostname.py +159 -0
- KL_Py/requests/urllib3/util/ssltransport.py +271 -0
- KL_Py/requests/urllib3/util/timeout.py +275 -0
- KL_Py/requests/urllib3/util/url.py +469 -0
- KL_Py/requests/urllib3/util/util.py +42 -0
- KL_Py/requests/urllib3/util/wait.py +124 -0
- KL_Py/requests/utils.py +1086 -0
- KL_Py/when.py +144 -0
- kl_py-0.0.1.dist-info/METADATA +15 -0
- kl_py-0.0.1.dist-info/RECORD +125 -0
- kl_py-0.0.1.dist-info/WHEEL +5 -0
- kl_py-0.0.1.dist-info/licenses/LICENSE +21 -0
- kl_py-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from encodings.aliases import aliases
|
|
4
|
+
from json import dumps
|
|
5
|
+
from re import sub
|
|
6
|
+
from typing import Any, Iterator, List, Tuple
|
|
7
|
+
|
|
8
|
+
from .constant import RE_POSSIBLE_ENCODING_INDICATION, TOO_BIG_SEQUENCE
|
|
9
|
+
from .utils import iana_name, is_multi_byte_encoding, unicode_range
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CharsetMatch:
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
payload: bytes,
|
|
16
|
+
guessed_encoding: str,
|
|
17
|
+
mean_mess_ratio: float,
|
|
18
|
+
has_sig_or_bom: bool,
|
|
19
|
+
languages: CoherenceMatches,
|
|
20
|
+
decoded_payload: str | None = None,
|
|
21
|
+
preemptive_declaration: str | None = None,
|
|
22
|
+
):
|
|
23
|
+
self._payload: bytes = payload
|
|
24
|
+
|
|
25
|
+
self._encoding: str = guessed_encoding
|
|
26
|
+
self._mean_mess_ratio: float = mean_mess_ratio
|
|
27
|
+
self._languages: CoherenceMatches = languages
|
|
28
|
+
self._has_sig_or_bom: bool = has_sig_or_bom
|
|
29
|
+
self._unicode_ranges: list[str] | None = None
|
|
30
|
+
|
|
31
|
+
self._leaves: list[CharsetMatch] = []
|
|
32
|
+
self._mean_coherence_ratio: float = 0.0
|
|
33
|
+
|
|
34
|
+
self._output_payload: bytes | None = None
|
|
35
|
+
self._output_encoding: str | None = None
|
|
36
|
+
|
|
37
|
+
self._string: str | None = decoded_payload
|
|
38
|
+
|
|
39
|
+
self._preemptive_declaration: str | None = preemptive_declaration
|
|
40
|
+
|
|
41
|
+
def __eq__(self, other: object) -> bool:
|
|
42
|
+
if not isinstance(other, CharsetMatch):
|
|
43
|
+
if isinstance(other, str):
|
|
44
|
+
return iana_name(other) == self.encoding
|
|
45
|
+
return False
|
|
46
|
+
return self.encoding == other.encoding and self.fingerprint == other.fingerprint
|
|
47
|
+
|
|
48
|
+
def __lt__(self, other: object) -> bool:
|
|
49
|
+
"""
|
|
50
|
+
Implemented to make sorted available upon CharsetMatches items.
|
|
51
|
+
"""
|
|
52
|
+
if not isinstance(other, CharsetMatch):
|
|
53
|
+
raise ValueError
|
|
54
|
+
|
|
55
|
+
chaos_difference: float = abs(self.chaos - other.chaos)
|
|
56
|
+
coherence_difference: float = abs(self.coherence - other.coherence)
|
|
57
|
+
|
|
58
|
+
# Below 1% difference --> Use Coherence
|
|
59
|
+
if chaos_difference < 0.01 and coherence_difference > 0.02:
|
|
60
|
+
return self.coherence > other.coherence
|
|
61
|
+
elif chaos_difference < 0.01 and coherence_difference <= 0.02:
|
|
62
|
+
# When having a difficult decision, use the result that decoded as many multi-byte as possible.
|
|
63
|
+
# preserve RAM usage!
|
|
64
|
+
if len(self._payload) >= TOO_BIG_SEQUENCE:
|
|
65
|
+
return self.chaos < other.chaos
|
|
66
|
+
return self.multi_byte_usage > other.multi_byte_usage
|
|
67
|
+
|
|
68
|
+
return self.chaos < other.chaos
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def multi_byte_usage(self) -> float:
|
|
72
|
+
return 1.0 - (len(str(self)) / len(self.raw))
|
|
73
|
+
|
|
74
|
+
def __str__(self) -> str:
|
|
75
|
+
# Lazy Str Loading
|
|
76
|
+
if self._string is None:
|
|
77
|
+
self._string = str(self._payload, self._encoding, "strict")
|
|
78
|
+
return self._string
|
|
79
|
+
|
|
80
|
+
def __repr__(self) -> str:
|
|
81
|
+
return f"<CharsetMatch '{self.encoding}' fp({self.fingerprint})>"
|
|
82
|
+
|
|
83
|
+
def add_submatch(self, other: CharsetMatch) -> None:
|
|
84
|
+
if not isinstance(other, CharsetMatch) or other == self:
|
|
85
|
+
raise ValueError(
|
|
86
|
+
"Unable to add instance <{}> as a submatch of a CharsetMatch".format(
|
|
87
|
+
other.__class__
|
|
88
|
+
)
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
other._string = None # Unload RAM usage; dirty trick.
|
|
92
|
+
self._leaves.append(other)
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def encoding(self) -> str:
|
|
96
|
+
return self._encoding
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def encoding_aliases(self) -> list[str]:
|
|
100
|
+
"""
|
|
101
|
+
Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
|
|
102
|
+
"""
|
|
103
|
+
also_known_as: list[str] = []
|
|
104
|
+
for u, p in aliases.items():
|
|
105
|
+
if self.encoding == u:
|
|
106
|
+
also_known_as.append(p)
|
|
107
|
+
elif self.encoding == p:
|
|
108
|
+
also_known_as.append(u)
|
|
109
|
+
return also_known_as
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def bom(self) -> bool:
|
|
113
|
+
return self._has_sig_or_bom
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def byte_order_mark(self) -> bool:
|
|
117
|
+
return self._has_sig_or_bom
|
|
118
|
+
|
|
119
|
+
@property
|
|
120
|
+
def languages(self) -> list[str]:
|
|
121
|
+
"""
|
|
122
|
+
Return the complete list of possible languages found in decoded sequence.
|
|
123
|
+
Usually not really useful. Returned list may be empty even if 'language' property return something != 'Unknown'.
|
|
124
|
+
"""
|
|
125
|
+
return [e[0] for e in self._languages]
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def language(self) -> str:
|
|
129
|
+
"""
|
|
130
|
+
Most probable language found in decoded sequence. If none were detected or inferred, the property will return
|
|
131
|
+
"Unknown".
|
|
132
|
+
"""
|
|
133
|
+
if not self._languages:
|
|
134
|
+
# Trying to infer the language based on the given encoding
|
|
135
|
+
# Its either English or we should not pronounce ourselves in certain cases.
|
|
136
|
+
if "ascii" in self.could_be_from_charset:
|
|
137
|
+
return "English"
|
|
138
|
+
|
|
139
|
+
# doing it there to avoid circular import
|
|
140
|
+
from charset_normalizer.cd import encoding_languages, mb_encoding_languages
|
|
141
|
+
|
|
142
|
+
languages = (
|
|
143
|
+
mb_encoding_languages(self.encoding)
|
|
144
|
+
if is_multi_byte_encoding(self.encoding)
|
|
145
|
+
else encoding_languages(self.encoding)
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
if len(languages) == 0 or "Latin Based" in languages:
|
|
149
|
+
return "Unknown"
|
|
150
|
+
|
|
151
|
+
return languages[0]
|
|
152
|
+
|
|
153
|
+
return self._languages[0][0]
|
|
154
|
+
|
|
155
|
+
@property
|
|
156
|
+
def chaos(self) -> float:
|
|
157
|
+
return self._mean_mess_ratio
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def coherence(self) -> float:
|
|
161
|
+
if not self._languages:
|
|
162
|
+
return 0.0
|
|
163
|
+
return self._languages[0][1]
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def percent_chaos(self) -> float:
|
|
167
|
+
return round(self.chaos * 100, ndigits=3)
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def percent_coherence(self) -> float:
|
|
171
|
+
return round(self.coherence * 100, ndigits=3)
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def raw(self) -> bytes:
|
|
175
|
+
"""
|
|
176
|
+
Original untouched bytes.
|
|
177
|
+
"""
|
|
178
|
+
return self._payload
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def submatch(self) -> list[CharsetMatch]:
|
|
182
|
+
return self._leaves
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def has_submatch(self) -> bool:
|
|
186
|
+
return len(self._leaves) > 0
|
|
187
|
+
|
|
188
|
+
@property
|
|
189
|
+
def alphabets(self) -> list[str]:
|
|
190
|
+
if self._unicode_ranges is not None:
|
|
191
|
+
return self._unicode_ranges
|
|
192
|
+
# list detected ranges
|
|
193
|
+
detected_ranges: list[str | None] = [unicode_range(char) for char in str(self)]
|
|
194
|
+
# filter and sort
|
|
195
|
+
self._unicode_ranges = sorted(list({r for r in detected_ranges if r}))
|
|
196
|
+
return self._unicode_ranges
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def could_be_from_charset(self) -> list[str]:
|
|
200
|
+
"""
|
|
201
|
+
The complete list of encoding that output the exact SAME str result and therefore could be the originating
|
|
202
|
+
encoding.
|
|
203
|
+
This list does include the encoding available in property 'encoding'.
|
|
204
|
+
"""
|
|
205
|
+
return [self._encoding] + [m.encoding for m in self._leaves]
|
|
206
|
+
|
|
207
|
+
def output(self, encoding: str = "utf_8") -> bytes:
|
|
208
|
+
"""
|
|
209
|
+
Method to get re-encoded bytes payload using given target encoding. Default to UTF-8.
|
|
210
|
+
Any errors will be simply ignored by the encoder NOT replaced.
|
|
211
|
+
"""
|
|
212
|
+
if self._output_encoding is None or self._output_encoding != encoding:
|
|
213
|
+
self._output_encoding = encoding
|
|
214
|
+
decoded_string = str(self)
|
|
215
|
+
if (
|
|
216
|
+
self._preemptive_declaration is not None
|
|
217
|
+
and self._preemptive_declaration.lower()
|
|
218
|
+
not in ["utf-8", "utf8", "utf_8"]
|
|
219
|
+
):
|
|
220
|
+
patched_header = sub(
|
|
221
|
+
RE_POSSIBLE_ENCODING_INDICATION,
|
|
222
|
+
lambda m: m.string[m.span()[0] : m.span()[1]].replace(
|
|
223
|
+
m.groups()[0],
|
|
224
|
+
iana_name(self._output_encoding).replace("_", "-"), # type: ignore[arg-type]
|
|
225
|
+
),
|
|
226
|
+
decoded_string[:8192],
|
|
227
|
+
count=1,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
decoded_string = patched_header + decoded_string[8192:]
|
|
231
|
+
|
|
232
|
+
self._output_payload = decoded_string.encode(encoding, "replace")
|
|
233
|
+
|
|
234
|
+
return self._output_payload # type: ignore
|
|
235
|
+
|
|
236
|
+
@property
|
|
237
|
+
def fingerprint(self) -> int:
|
|
238
|
+
"""
|
|
239
|
+
Retrieve a hash fingerprint of the decoded payload, used for deduplication.
|
|
240
|
+
"""
|
|
241
|
+
return hash(str(self))
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class CharsetMatches:
|
|
245
|
+
"""
|
|
246
|
+
Container with every CharsetMatch items ordered by default from most probable to the less one.
|
|
247
|
+
Act like a list(iterable) but does not implements all related methods.
|
|
248
|
+
"""
|
|
249
|
+
|
|
250
|
+
def __init__(self, results: list[CharsetMatch] | None = None):
|
|
251
|
+
self._results: list[CharsetMatch] = sorted(results) if results else []
|
|
252
|
+
|
|
253
|
+
def __iter__(self) -> Iterator[CharsetMatch]:
|
|
254
|
+
yield from self._results
|
|
255
|
+
|
|
256
|
+
def __getitem__(self, item: int | str) -> CharsetMatch:
|
|
257
|
+
"""
|
|
258
|
+
Retrieve a single item either by its position or encoding name (alias may be used here).
|
|
259
|
+
Raise KeyError upon invalid index or encoding not present in results.
|
|
260
|
+
"""
|
|
261
|
+
if isinstance(item, int):
|
|
262
|
+
return self._results[item]
|
|
263
|
+
if isinstance(item, str):
|
|
264
|
+
item = iana_name(item, False)
|
|
265
|
+
for result in self._results:
|
|
266
|
+
if item in result.could_be_from_charset:
|
|
267
|
+
return result
|
|
268
|
+
raise KeyError
|
|
269
|
+
|
|
270
|
+
def __len__(self) -> int:
|
|
271
|
+
return len(self._results)
|
|
272
|
+
|
|
273
|
+
def __bool__(self) -> bool:
|
|
274
|
+
return len(self._results) > 0
|
|
275
|
+
|
|
276
|
+
def append(self, item: CharsetMatch) -> None:
|
|
277
|
+
"""
|
|
278
|
+
Insert a single match. Will be inserted accordingly to preserve sort.
|
|
279
|
+
Can be inserted as a submatch.
|
|
280
|
+
"""
|
|
281
|
+
if not isinstance(item, CharsetMatch):
|
|
282
|
+
raise ValueError(
|
|
283
|
+
"Cannot append instance '{}' to CharsetMatches".format(
|
|
284
|
+
str(item.__class__)
|
|
285
|
+
)
|
|
286
|
+
)
|
|
287
|
+
# We should disable the submatch factoring when the input file is too heavy (conserve RAM usage)
|
|
288
|
+
if len(item.raw) < TOO_BIG_SEQUENCE:
|
|
289
|
+
for match in self._results:
|
|
290
|
+
if match.fingerprint == item.fingerprint and match.chaos == item.chaos:
|
|
291
|
+
match.add_submatch(item)
|
|
292
|
+
return
|
|
293
|
+
self._results.append(item)
|
|
294
|
+
self._results = sorted(self._results)
|
|
295
|
+
|
|
296
|
+
def best(self) -> CharsetMatch | None:
|
|
297
|
+
"""
|
|
298
|
+
Simply return the first match. Strict equivalent to matches[0].
|
|
299
|
+
"""
|
|
300
|
+
if not self._results:
|
|
301
|
+
return None
|
|
302
|
+
return self._results[0]
|
|
303
|
+
|
|
304
|
+
def first(self) -> CharsetMatch | None:
|
|
305
|
+
"""
|
|
306
|
+
Redundant method, call the method best(). Kept for BC reasons.
|
|
307
|
+
"""
|
|
308
|
+
return self.best()
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
CoherenceMatch = Tuple[str, float]
|
|
312
|
+
CoherenceMatches = List[CoherenceMatch]
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
class CliDetectionResult:
|
|
316
|
+
def __init__(
|
|
317
|
+
self,
|
|
318
|
+
path: str,
|
|
319
|
+
encoding: str | None,
|
|
320
|
+
encoding_aliases: list[str],
|
|
321
|
+
alternative_encodings: list[str],
|
|
322
|
+
language: str,
|
|
323
|
+
alphabets: list[str],
|
|
324
|
+
has_sig_or_bom: bool,
|
|
325
|
+
chaos: float,
|
|
326
|
+
coherence: float,
|
|
327
|
+
unicode_path: str | None,
|
|
328
|
+
is_preferred: bool,
|
|
329
|
+
):
|
|
330
|
+
self.path: str = path
|
|
331
|
+
self.unicode_path: str | None = unicode_path
|
|
332
|
+
self.encoding: str | None = encoding
|
|
333
|
+
self.encoding_aliases: list[str] = encoding_aliases
|
|
334
|
+
self.alternative_encodings: list[str] = alternative_encodings
|
|
335
|
+
self.language: str = language
|
|
336
|
+
self.alphabets: list[str] = alphabets
|
|
337
|
+
self.has_sig_or_bom: bool = has_sig_or_bom
|
|
338
|
+
self.chaos: float = chaos
|
|
339
|
+
self.coherence: float = coherence
|
|
340
|
+
self.is_preferred: bool = is_preferred
|
|
341
|
+
|
|
342
|
+
@property
|
|
343
|
+
def __dict__(self) -> dict[str, Any]: # type: ignore
|
|
344
|
+
return {
|
|
345
|
+
"path": self.path,
|
|
346
|
+
"encoding": self.encoding,
|
|
347
|
+
"encoding_aliases": self.encoding_aliases,
|
|
348
|
+
"alternative_encodings": self.alternative_encodings,
|
|
349
|
+
"language": self.language,
|
|
350
|
+
"alphabets": self.alphabets,
|
|
351
|
+
"has_sig_or_bom": self.has_sig_or_bom,
|
|
352
|
+
"chaos": self.chaos,
|
|
353
|
+
"coherence": self.coherence,
|
|
354
|
+
"unicode_path": self.unicode_path,
|
|
355
|
+
"is_preferred": self.is_preferred,
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
def to_json(self) -> str:
|
|
359
|
+
return dumps(self.__dict__, ensure_ascii=True, indent=4)
|
|
File without changes
|