dissect.cstruct 5.0.dev22__py3-none-any.whl → 5.0.dev24__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.
- dissect/cstruct/cstruct.py +21 -1
- {dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/METADATA +1 -1
- {dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/RECORD +8 -8
- {dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/WHEEL +0 -0
- {dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/entry_points.txt +0 -0
- {dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/licenses/COPYRIGHT +0 -0
- {dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/licenses/LICENSE +0 -0
- {dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/top_level.txt +0 -0
dissect/cstruct/cstruct.py
CHANGED
|
@@ -60,7 +60,7 @@ class cstruct:
|
|
|
60
60
|
DEF_LEGACY = 2
|
|
61
61
|
|
|
62
62
|
def __init__(self, load: str = "", *, endian: AllowedEndianness = "<", pointer: str | None = None):
|
|
63
|
-
self.endian =
|
|
63
|
+
self.endian = endian
|
|
64
64
|
|
|
65
65
|
self.consts: dict[str, int | str | bytes] = {}
|
|
66
66
|
self.types: dict[str, type[BaseType]] = {}
|
|
@@ -260,6 +260,17 @@ class cstruct:
|
|
|
260
260
|
|
|
261
261
|
return cs
|
|
262
262
|
|
|
263
|
+
# Hidden from type checkers, which otherwise accept assigning any attribute, e.g. a misspelled one
|
|
264
|
+
if not TYPE_CHECKING:
|
|
265
|
+
|
|
266
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
|
267
|
+
# Normalize ``endian`` when it's set, so ``cs.endian = "big"`` works like the ``endian`` argument.
|
|
268
|
+
# This is done in __setattr__ because ``cs.endian`` is read on every parse, so this keeps reading fast.
|
|
269
|
+
# All alternatives cause slowdowns when reading (property, descriptor)
|
|
270
|
+
if name == "endian":
|
|
271
|
+
value = normalize_endianness(value)
|
|
272
|
+
super().__setattr__(name, value)
|
|
273
|
+
|
|
263
274
|
def _next_anonymous(self) -> str:
|
|
264
275
|
name = f"__anonymous_{self._anonymous_count}__"
|
|
265
276
|
self._anonymous_count += 1
|
|
@@ -622,6 +633,15 @@ class cstruct:
|
|
|
622
633
|
_int = int
|
|
623
634
|
_float = float
|
|
624
635
|
|
|
636
|
+
# At runtime ``endian`` is a plain attribute that ``__setattr__`` normalizes, so reading it stays fast.
|
|
637
|
+
# Type checkers see a property, so that setting accepts every allowed value and reading gives the
|
|
638
|
+
# normalized one.
|
|
639
|
+
@property
|
|
640
|
+
def endian(self) -> Endianness: ...
|
|
641
|
+
|
|
642
|
+
@endian.setter
|
|
643
|
+
def endian(self, value: AllowedEndianness) -> None: ...
|
|
644
|
+
|
|
625
645
|
class int8(_int, Packed[_int]): ...
|
|
626
646
|
|
|
627
647
|
class uint8(_int, Packed[_int]): ...
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 5.0.
|
|
3
|
+
Version: 5.0.dev24
|
|
4
4
|
Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
|
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
dissect/cstruct/__init__.py,sha256=6WCBCk9iTJiKjzfkYCZAwWkIh3FnxEuCe_y2TSUJ2bU,1905
|
|
2
2
|
dissect/cstruct/bitbuffer.py,sha256=FpvyoDuio0hLfUtyqb2OUg1SpDVnblxMVNtAbYLPzVk,2781
|
|
3
3
|
dissect/cstruct/compiler.py,sha256=6mK2CdUnfWdQIu0_1qIL1NCaaqlv5eJcvlamMsGfEAg,54781
|
|
4
|
-
dissect/cstruct/cstruct.py,sha256=
|
|
4
|
+
dissect/cstruct/cstruct.py,sha256=quHzIZoM6ADQrfrMPsQ-QzxJ-9D2glYHWwSQXn7cysM,27645
|
|
5
5
|
dissect/cstruct/declarative.py,sha256=GPU208IsslegjFug9udduu-6fhmV2CIfIf6oY76ycEw,14571
|
|
6
6
|
dissect/cstruct/dump.py,sha256=W5ISbaZ-1YmWXKzh-x6pDt5_SlpFRDhD9GGNyv1MnLw,19016
|
|
7
7
|
dissect/cstruct/exception.py,sha256=8b_nLXacWGdQ3BhZN-DOOEr4gp5Vacni6etwDKqYHis,988
|
|
@@ -23,10 +23,10 @@ dissect/cstruct/types/pointer.py,sha256=pIxiDGosRu1jhchdcA3Zm7yIXkPUh2UKnIt8kxUy
|
|
|
23
23
|
dissect/cstruct/types/structure.py,sha256=T28ZncDWG2QtkQcpKNwfpNmk5_77IgW0idDxHINzcFY,43638
|
|
24
24
|
dissect/cstruct/types/void.py,sha256=fV4hKk50uop_EKbR1nfy1cdtAzvUYrSymXsdakCyFk8,1222
|
|
25
25
|
dissect/cstruct/types/wchar.py,sha256=eJyOWdT8Y3k8gM9QNE0NeXBwcAGRcp4aUkIBezAYe0c,4225
|
|
26
|
-
dissect_cstruct-5.0.
|
|
27
|
-
dissect_cstruct-5.0.
|
|
28
|
-
dissect_cstruct-5.0.
|
|
29
|
-
dissect_cstruct-5.0.
|
|
30
|
-
dissect_cstruct-5.0.
|
|
31
|
-
dissect_cstruct-5.0.
|
|
32
|
-
dissect_cstruct-5.0.
|
|
26
|
+
dissect_cstruct-5.0.dev24.dist-info/licenses/COPYRIGHT,sha256=H-18RXfshdH9AdHwW2eO1Xa-5s6tY5eipHh5c0whDu4,316
|
|
27
|
+
dissect_cstruct-5.0.dev24.dist-info/licenses/LICENSE,sha256=PhUqiw6jAh2KbBdVRPBq_hfAvfcTBin7nZ3CK7NQbTM,11341
|
|
28
|
+
dissect_cstruct-5.0.dev24.dist-info/METADATA,sha256=TwINfkCJixnZO2mCLvYnMw5DvUJxNIOfdIbf4o7wMeI,12661
|
|
29
|
+
dissect_cstruct-5.0.dev24.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
30
|
+
dissect_cstruct-5.0.dev24.dist-info/entry_points.txt,sha256=z53zqZqwD2OLrAkRwrP4wTeiU9CQe7xrMly0T2c0_wQ,71
|
|
31
|
+
dissect_cstruct-5.0.dev24.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
|
|
32
|
+
dissect_cstruct-5.0.dev24.dist-info/RECORD,,
|
|
File without changes
|
{dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/licenses/COPYRIGHT
RENAMED
|
File without changes
|
{dissect_cstruct-5.0.dev22.dist-info → dissect_cstruct-5.0.dev24.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|