dissect.cstruct 4.0.dev0__tar.gz → 4.0.dev2__tar.gz
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-4.0.dev0/dissect.cstruct.egg-info → dissect_cstruct-4.0.dev2}/PKG-INFO +1 -1
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/expression.py +3 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/enum.py +12 -7
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2/dissect.cstruct.egg-info}/PKG-INFO +1 -1
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/pyproject.toml +1 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_expression.py +1 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_enum.py +12 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/COPYRIGHT +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/LICENSE +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/MANIFEST.in +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/README.md +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/__init__.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/bitbuffer.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/compiler.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/cstruct.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/exceptions.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/parser.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/__init__.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/base.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/char.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/flag.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/int.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/leb128.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/packed.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/pointer.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/structure.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/void.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/types/wchar.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect/cstruct/utils.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect.cstruct.egg-info/top_level.txt +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/examples/disk.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/examples/mirai.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/examples/pe.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/examples/protobuf.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/examples/secdesc.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/setup.cfg +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/__init__.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/conftest.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/data/testdef.txt +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/docs/Makefile +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/docs/conf.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/docs/index.rst +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_align.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_basic.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_bitbuffer.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_bitfield.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_compiler.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_ctypes.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_parser.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_base.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_char.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_custom.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_flag.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_int.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_leb128.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_packed.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_pointer.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_structure.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_union.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_void.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_types_wchar.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/test_utils.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tests/utils.py +0 -0
- {dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.dev2
|
|
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: Apache License 2.0
|
|
@@ -11,6 +11,7 @@ if TYPE_CHECKING:
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
PY_311 = sys.version_info >= (3, 11, 0)
|
|
14
|
+
PY_312 = sys.version_info >= (3, 12, 0)
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class EnumMetaType(EnumMeta, MetaType):
|
|
@@ -56,6 +57,13 @@ class EnumMetaType(EnumMeta, MetaType):
|
|
|
56
57
|
|
|
57
58
|
__len__ = MetaType.__len__
|
|
58
59
|
|
|
60
|
+
if not PY_312:
|
|
61
|
+
# Backport __contains__ from CPython 3.12
|
|
62
|
+
def __contains__(cls, value: Any) -> bool:
|
|
63
|
+
if isinstance(value, cls):
|
|
64
|
+
return True
|
|
65
|
+
return value in cls._value2member_map_
|
|
66
|
+
|
|
59
67
|
def _read(cls, stream: BinaryIO, context: dict[str, Any] = None) -> Enum:
|
|
60
68
|
return cls(cls.type._read(stream, context))
|
|
61
69
|
|
|
@@ -174,10 +182,7 @@ class Enum(BaseType, IntEnum, metaclass=EnumMetaType):
|
|
|
174
182
|
@classmethod
|
|
175
183
|
def _missing_(cls, value: int) -> Enum:
|
|
176
184
|
# Emulate FlagBoundary.KEEP for enum (allow values other than the defined members)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
new_member._value_ = value
|
|
182
|
-
pseudo_member = cls._value2member_map_.setdefault(value, new_member)
|
|
183
|
-
return pseudo_member
|
|
185
|
+
new_member = int.__new__(cls, value)
|
|
186
|
+
new_member._name_ = None
|
|
187
|
+
new_member._value_ = value
|
|
188
|
+
return new_member
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.dev2
|
|
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: Apache License 2.0
|
|
@@ -94,6 +94,7 @@ def test_expression(expression: str, answer: int) -> None:
|
|
|
94
94
|
("-", ExpressionParserError, "Invalid expression: not enough operands"),
|
|
95
95
|
("(", ExpressionParserError, "Invalid expression"),
|
|
96
96
|
(")", ExpressionParserError, "Invalid expression"),
|
|
97
|
+
(" ", ExpressionParserError, "Invalid expression"),
|
|
97
98
|
("()", ExpressionParserError, "Parser expected an expression, instead received empty parenthesis. Index: 1"),
|
|
98
99
|
("0()", ExpressionParserError, "Parser expected sizeof or an arethmethic operator instead got: '0'"),
|
|
99
100
|
("sizeof)", ExpressionParserError, "Invalid sizeof operation"),
|
|
@@ -34,6 +34,18 @@ def test_enum(cs: cstruct, TestEnum: type[Enum]) -> None:
|
|
|
34
34
|
assert TestEnum(0).name is None
|
|
35
35
|
assert TestEnum(0).value == 0
|
|
36
36
|
|
|
37
|
+
assert 0 not in TestEnum
|
|
38
|
+
assert 1 in TestEnum
|
|
39
|
+
assert 2 in TestEnum
|
|
40
|
+
assert 3 in TestEnum
|
|
41
|
+
assert 4 not in TestEnum
|
|
42
|
+
|
|
43
|
+
assert TestEnum.A in TestEnum
|
|
44
|
+
|
|
45
|
+
# Mixing enums is not allowed
|
|
46
|
+
OtherEnum = cs._make_enum("Other", cs.uint8, {"A": 1, "B": 2, "C": 3})
|
|
47
|
+
assert OtherEnum.A not in TestEnum
|
|
48
|
+
|
|
37
49
|
|
|
38
50
|
def test_enum_read(TestEnum: type[Enum]) -> None:
|
|
39
51
|
assert TestEnum(b"\x02") == TestEnum.B
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect.cstruct.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{dissect_cstruct-4.0.dev0 → dissect_cstruct-4.0.dev2}/dissect.cstruct.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|