dissect.cstruct 4.6.dev7__tar.gz → 4.7.dev1__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.6.dev7 → dissect_cstruct-4.7.dev1}/PKG-INFO +3 -4
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/cstruct.py +1 -2
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/expression.py +3 -1
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/parser.py +13 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/tools/stubgen.py +1 -2
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/base.py +3 -5
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/structure.py +3 -3
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/PKG-INFO +3 -4
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/pyproject.toml +26 -8
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_basic.py +1 -1
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_parser.py +14 -1
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_tools_stubgen.py +1 -2
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tox.ini +8 -12
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/.git-blame-ignore-revs +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/.gitattributes +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/CHANGELOG.md +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/COPYRIGHT +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/LICENSE +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/MANIFEST.in +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/README.md +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/bitbuffer.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/compiler.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/exceptions.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/tools/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/char.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/enum.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/flag.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/int.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/leb128.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/packed.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/pointer.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/void.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/types/wchar.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect/cstruct/utils.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/entry_points.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/requires.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/top_level.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/examples/disk.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/examples/mirai.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/examples/pe.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/examples/protobuf.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/examples/secdesc.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/setup.cfg +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/_data/testdef.txt +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/_docs/Makefile +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/_docs/__init__.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/_docs/conf.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/_docs/index.rst +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/conftest.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_align.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_annotations.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_bitbuffer.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_bitfield.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_compiler.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_ctypes.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_expression.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_base.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_char.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_custom.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_enum.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_flag.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_int.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_leb128.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_packed.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_pointer.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_structure.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_union.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_void.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_types_wchar.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/test_utils.py +0 -0
- {dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/tests/utils.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.7.dev1
|
|
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
|
-
License: Apache
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
7
|
Project-URL: homepage, https://dissect.tools
|
|
8
8
|
Project-URL: documentation, https://docs.dissect.tools/en/latest/projects/dissect.cstruct
|
|
9
9
|
Project-URL: repository, https://github.com/fox-it/dissect.cstruct
|
|
@@ -12,14 +12,13 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
12
12
|
Classifier: Environment :: Console
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
14
|
Classifier: Intended Audience :: Information Technology
|
|
15
|
-
Classifier: License :: OSI Approved
|
|
16
15
|
Classifier: Operating System :: OS Independent
|
|
17
16
|
Classifier: Programming Language :: Python :: 3
|
|
18
17
|
Classifier: Topic :: Internet :: Log Analysis
|
|
19
18
|
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
20
19
|
Classifier: Topic :: Security
|
|
21
20
|
Classifier: Topic :: Utilities
|
|
22
|
-
Requires-Python:
|
|
21
|
+
Requires-Python: >=3.10
|
|
23
22
|
Description-Content-Type: text/markdown
|
|
24
23
|
License-File: LICENSE
|
|
25
24
|
License-File: COPYRIGHT
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import string
|
|
4
|
-
from typing import TYPE_CHECKING,
|
|
4
|
+
from typing import TYPE_CHECKING, ClassVar
|
|
5
5
|
|
|
6
6
|
from dissect.cstruct.exceptions import ExpressionParserError, ExpressionTokenizerError
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
|
+
from collections.abc import Callable
|
|
10
|
+
|
|
9
11
|
from dissect.cstruct import cstruct
|
|
10
12
|
|
|
11
13
|
|
|
@@ -57,6 +57,7 @@ class TokenParser(Parser):
|
|
|
57
57
|
TOK = TokenCollection()
|
|
58
58
|
TOK.add(r"#\[(?P<values>[^\]]+)\](?=\s*)", "CONFIG_FLAG")
|
|
59
59
|
TOK.add(r"#define\s+(?P<name>[^\s]+)(?P<value>[^\r\n]*)", "DEFINE")
|
|
60
|
+
TOK.add(r"#undef\s+(?P<name>[^\s]+)\s*", "UNDEF")
|
|
60
61
|
TOK.add(r"#ifdef\s+(?P<name>[^\s]+)\s*", "IFDEF")
|
|
61
62
|
TOK.add(r"#ifndef\s+(?P<name>[^\s]+)\s*", "IFNDEF")
|
|
62
63
|
TOK.add(r"#else\s*", "ELSE")
|
|
@@ -154,6 +155,16 @@ class TokenParser(Parser):
|
|
|
154
155
|
|
|
155
156
|
self.cstruct.consts[match["name"]] = value
|
|
156
157
|
|
|
158
|
+
def _undef(self, tokens: TokenConsumer) -> None:
|
|
159
|
+
const = tokens.consume()
|
|
160
|
+
pattern = self.TOK.patterns[self.TOK.UNDEF]
|
|
161
|
+
match = pattern.match(const.value).groupdict()
|
|
162
|
+
|
|
163
|
+
if match["name"] in self.cstruct.consts:
|
|
164
|
+
del self.cstruct.consts[match["name"]]
|
|
165
|
+
else:
|
|
166
|
+
raise ParserError(f"line {self._lineno(const)}: constant {match['name']!r} not defined")
|
|
167
|
+
|
|
157
168
|
def _enum(self, tokens: TokenConsumer) -> None:
|
|
158
169
|
# We cheat with enums because the entire enum is in the token
|
|
159
170
|
etok = tokens.consume()
|
|
@@ -443,6 +454,8 @@ class TokenParser(Parser):
|
|
|
443
454
|
self._config_flag(tokens)
|
|
444
455
|
elif token == self.TOK.DEFINE:
|
|
445
456
|
self._constant(tokens)
|
|
457
|
+
elif token == self.TOK.UNDEF:
|
|
458
|
+
self._undef(tokens)
|
|
446
459
|
elif token == self.TOK.TYPEDEF:
|
|
447
460
|
self._typedef(tokens)
|
|
448
461
|
elif token == self.TOK.STRUCT:
|
|
@@ -39,10 +39,9 @@ def generate_file_stub(path: Path, base: Path) -> str:
|
|
|
39
39
|
|
|
40
40
|
header = [
|
|
41
41
|
"# Generated by cstruct-stubgen",
|
|
42
|
-
"from typing import BinaryIO, Literal, overload",
|
|
42
|
+
"from typing import BinaryIO, Literal, TypeAlias, overload",
|
|
43
43
|
"",
|
|
44
44
|
"import dissect.cstruct as __cs__",
|
|
45
|
-
"from typing_extensions import TypeAlias",
|
|
46
45
|
]
|
|
47
46
|
body = []
|
|
48
47
|
|
|
@@ -2,12 +2,14 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import functools
|
|
4
4
|
from io import BytesIO
|
|
5
|
-
from typing import TYPE_CHECKING, Any, BinaryIO,
|
|
5
|
+
from typing import TYPE_CHECKING, Any, BinaryIO, ClassVar, TypeVar
|
|
6
6
|
|
|
7
7
|
from dissect.cstruct.exceptions import ArraySizeError
|
|
8
8
|
from dissect.cstruct.expression import Expression
|
|
9
9
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
|
+
from collections.abc import Callable
|
|
12
|
+
|
|
11
13
|
from typing_extensions import Self
|
|
12
14
|
|
|
13
15
|
from dissect.cstruct.cstruct import cstruct
|
|
@@ -60,10 +62,6 @@ class MetaType(type):
|
|
|
60
62
|
|
|
61
63
|
def __len__(cls) -> int:
|
|
62
64
|
"""Return the byte size of the type."""
|
|
63
|
-
# Python 3.9 compat thing for bound type vars
|
|
64
|
-
if cls is BaseType:
|
|
65
|
-
return 0
|
|
66
|
-
|
|
67
65
|
if cls.size is None:
|
|
68
66
|
raise TypeError("Dynamic size")
|
|
69
67
|
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import io
|
|
4
4
|
from collections import ChainMap
|
|
5
|
-
from collections.abc import MutableMapping
|
|
5
|
+
from collections.abc import Callable, MutableMapping
|
|
6
6
|
from contextlib import contextmanager
|
|
7
7
|
from enum import Enum
|
|
8
8
|
from functools import lru_cache
|
|
@@ -10,7 +10,7 @@ from itertools import chain
|
|
|
10
10
|
from operator import attrgetter
|
|
11
11
|
from textwrap import dedent
|
|
12
12
|
from types import FunctionType
|
|
13
|
-
from typing import TYPE_CHECKING, Any, BinaryIO
|
|
13
|
+
from typing import TYPE_CHECKING, Any, BinaryIO
|
|
14
14
|
|
|
15
15
|
from dissect.cstruct.bitbuffer import BitBuffer
|
|
16
16
|
from dissect.cstruct.types.base import (
|
|
@@ -467,7 +467,7 @@ class UnionMetaType(StructureMetaType):
|
|
|
467
467
|
|
|
468
468
|
# User (partial) initialization, rebuild the union
|
|
469
469
|
# First user-provided field is the one used to rebuild the union
|
|
470
|
-
arg_fields = (field._name for _, field in zip(args, cls.__fields__))
|
|
470
|
+
arg_fields = (field._name for _, field in zip(args, cls.__fields__, strict=False))
|
|
471
471
|
kwarg_fields = (name for name in kwargs if name in cls.lookup)
|
|
472
472
|
if (first_field := next(chain(arg_fields, kwarg_fields), None)) is not None:
|
|
473
473
|
obj._rebuild(first_field)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.7.dev1
|
|
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
|
-
License: Apache
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
7
|
Project-URL: homepage, https://dissect.tools
|
|
8
8
|
Project-URL: documentation, https://docs.dissect.tools/en/latest/projects/dissect.cstruct
|
|
9
9
|
Project-URL: repository, https://github.com/fox-it/dissect.cstruct
|
|
@@ -12,14 +12,13 @@ Classifier: Development Status :: 5 - Production/Stable
|
|
|
12
12
|
Classifier: Environment :: Console
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
14
14
|
Classifier: Intended Audience :: Information Technology
|
|
15
|
-
Classifier: License :: OSI Approved
|
|
16
15
|
Classifier: Operating System :: OS Independent
|
|
17
16
|
Classifier: Programming Language :: Python :: 3
|
|
18
17
|
Classifier: Topic :: Internet :: Log Analysis
|
|
19
18
|
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
20
19
|
Classifier: Topic :: Security
|
|
21
20
|
Classifier: Topic :: Utilities
|
|
22
|
-
Requires-Python:
|
|
21
|
+
Requires-Python: >=3.10
|
|
23
22
|
Description-Content-Type: text/markdown
|
|
24
23
|
License-File: LICENSE
|
|
25
24
|
License-File: COPYRIGHT
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools>=
|
|
2
|
+
requires = ["setuptools>=77.0.0", "setuptools_scm[toml]>=6.4.0"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dissect.cstruct"
|
|
7
7
|
description = "A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy"
|
|
8
8
|
readme = "README.md"
|
|
9
|
-
requires-python = "
|
|
10
|
-
license
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE", "COPYRIGHT"]
|
|
11
12
|
authors = [
|
|
12
13
|
{name = "Dissect Team", email = "dissect@fox-it.com"}
|
|
13
14
|
]
|
|
@@ -16,7 +17,6 @@ classifiers = [
|
|
|
16
17
|
"Environment :: Console",
|
|
17
18
|
"Intended Audience :: Developers",
|
|
18
19
|
"Intended Audience :: Information Technology",
|
|
19
|
-
"License :: OSI Approved",
|
|
20
20
|
"Operating System :: OS Independent",
|
|
21
21
|
"Programming Language :: Python :: 3",
|
|
22
22
|
"Topic :: Internet :: Log Analysis",
|
|
@@ -37,12 +37,33 @@ dev = [
|
|
|
37
37
|
"typing_extensions"
|
|
38
38
|
]
|
|
39
39
|
|
|
40
|
+
[dependency-groups]
|
|
41
|
+
test = [
|
|
42
|
+
"pytest",
|
|
43
|
+
]
|
|
44
|
+
lint = [
|
|
45
|
+
"ruff==0.13.1",
|
|
46
|
+
"typing_extensions",
|
|
47
|
+
"vermin",
|
|
48
|
+
]
|
|
49
|
+
build = [
|
|
50
|
+
"build",
|
|
51
|
+
]
|
|
52
|
+
debug = [
|
|
53
|
+
"ipdb",
|
|
54
|
+
]
|
|
55
|
+
dev = [
|
|
56
|
+
{include-group = "test"},
|
|
57
|
+
{include-group = "lint"},
|
|
58
|
+
{include-group = "debug"},
|
|
59
|
+
]
|
|
60
|
+
|
|
40
61
|
[project.scripts]
|
|
41
62
|
cstruct-stubgen = "dissect.cstruct.tools.stubgen:main"
|
|
42
63
|
|
|
43
64
|
[tool.ruff]
|
|
44
65
|
line-length = 120
|
|
45
|
-
required-version = ">=0.
|
|
66
|
+
required-version = ">=0.13.1"
|
|
46
67
|
|
|
47
68
|
[tool.ruff.format]
|
|
48
69
|
docstring-code-format = true
|
|
@@ -91,9 +112,6 @@ ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM1
|
|
|
91
112
|
known-first-party = ["dissect.cstruct"]
|
|
92
113
|
known-third-party = ["dissect"]
|
|
93
114
|
|
|
94
|
-
[tool.setuptools]
|
|
95
|
-
license-files = ["LICENSE", "COPYRIGHT"]
|
|
96
|
-
|
|
97
115
|
[tool.setuptools.packages.find]
|
|
98
116
|
include = ["dissect.*"]
|
|
99
117
|
|
|
@@ -77,7 +77,7 @@ def test_load_init_kwargs_only() -> None:
|
|
|
77
77
|
"""
|
|
78
78
|
|
|
79
79
|
# kwargs only check
|
|
80
|
-
with pytest.raises(TypeError, match="takes from .* positional arguments but .* were given"):
|
|
80
|
+
with pytest.raises(TypeError, match=r"takes from .* positional arguments but .* were given"):
|
|
81
81
|
cs = cstruct(cdef, ">")
|
|
82
82
|
|
|
83
83
|
cs = cstruct(cdef, endian=">")
|
|
@@ -163,6 +163,19 @@ def test_typedef_pointer(cs: cstruct) -> None:
|
|
|
163
163
|
assert cs.PIMAGE_DATA_DIRECTORY.type == cs._IMAGE_DATA_DIRECTORY
|
|
164
164
|
|
|
165
165
|
|
|
166
|
+
def test_undef(cs: cstruct) -> None:
|
|
167
|
+
cdef = """
|
|
168
|
+
#define MY_CONST 42
|
|
169
|
+
#undef MY_CONST
|
|
170
|
+
"""
|
|
171
|
+
cs.load(cdef)
|
|
172
|
+
|
|
173
|
+
assert "MY_CONST" not in cs.consts
|
|
174
|
+
|
|
175
|
+
with pytest.raises(ParserError, match="line 1: constant 'MY_CONST' not defined"):
|
|
176
|
+
cs.load("#undef MY_CONST") # This should raise an error since MY_CONST is not defined
|
|
177
|
+
|
|
178
|
+
|
|
166
179
|
def test_conditional_ifdef(cs: cstruct) -> None:
|
|
167
180
|
cdef = """
|
|
168
181
|
#define MY_CONST 42
|
|
@@ -269,7 +282,7 @@ def test_conditional_parsing_error(cs: cstruct) -> None:
|
|
|
269
282
|
};
|
|
270
283
|
#endif
|
|
271
284
|
"""
|
|
272
|
-
with pytest.raises(ParserError, match="line 8: unexpected token .+ENDIF"):
|
|
285
|
+
with pytest.raises(ParserError, match=r"line 8: unexpected token .+ENDIF"):
|
|
273
286
|
cs.load(cdef)
|
|
274
287
|
|
|
275
288
|
cdef = """
|
|
@@ -376,10 +376,9 @@ def test_generate_file_stub(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, cap
|
|
|
376
376
|
|
|
377
377
|
expected = """
|
|
378
378
|
# Generated by cstruct-stubgen
|
|
379
|
-
from typing import BinaryIO, Literal, overload
|
|
379
|
+
from typing import BinaryIO, Literal, TypeAlias, overload
|
|
380
380
|
|
|
381
381
|
import dissect.cstruct as __cs__
|
|
382
|
-
from typing_extensions import TypeAlias
|
|
383
382
|
|
|
384
383
|
class _c_structure(__cs__.cstruct):
|
|
385
384
|
class Test(__cs__.Structure):
|
|
@@ -4,7 +4,7 @@ envlist = lint, py3, pypy3
|
|
|
4
4
|
# requires if they are not available on the host system. This requires the
|
|
5
5
|
# locally installed tox to have a minimum version 3.3.0. This means the names
|
|
6
6
|
# of the configuration options are still according to the tox 3.x syntax.
|
|
7
|
-
minversion = 4.
|
|
7
|
+
minversion = 4.27.0
|
|
8
8
|
# This version of virtualenv will install setuptools version 68.2.2 and pip
|
|
9
9
|
# 23.3.1. These versions fully support python projects defined only through a
|
|
10
10
|
# pyproject.toml file (PEP-517/PEP-518/PEP-621). This pip version also support
|
|
@@ -14,9 +14,9 @@ requires = virtualenv>=20.24.6
|
|
|
14
14
|
[testenv]
|
|
15
15
|
extras = dev
|
|
16
16
|
deps =
|
|
17
|
-
pytest
|
|
18
17
|
pytest-cov
|
|
19
18
|
coverage
|
|
19
|
+
dependency_groups = test
|
|
20
20
|
commands =
|
|
21
21
|
pytest --basetemp="{envtmpdir}" {posargs:--color=yes --cov=dissect --cov-report=term-missing -v tests}
|
|
22
22
|
coverage report
|
|
@@ -24,28 +24,24 @@ commands =
|
|
|
24
24
|
|
|
25
25
|
[testenv:build]
|
|
26
26
|
package = skip
|
|
27
|
-
|
|
28
|
-
build
|
|
27
|
+
dependency_groups = build
|
|
29
28
|
commands =
|
|
30
29
|
pyproject-build
|
|
31
30
|
|
|
32
31
|
[testenv:fix]
|
|
33
32
|
package = skip
|
|
34
|
-
|
|
35
|
-
ruff==0.12.4
|
|
33
|
+
dependency_groups = lint
|
|
36
34
|
commands =
|
|
37
|
-
ruff format dissect tests
|
|
38
35
|
ruff check --fix dissect tests
|
|
36
|
+
ruff format dissect tests
|
|
39
37
|
|
|
40
38
|
[testenv:lint]
|
|
41
39
|
package = skip
|
|
42
|
-
|
|
43
|
-
ruff==0.12.4
|
|
44
|
-
vermin
|
|
40
|
+
dependency_groups = lint
|
|
45
41
|
commands =
|
|
46
|
-
ruff format --check dissect tests
|
|
47
42
|
ruff check dissect tests
|
|
48
|
-
|
|
43
|
+
ruff format --check dissect tests
|
|
44
|
+
vermin -t=3.10- --no-tips --lint dissect tests
|
|
49
45
|
|
|
50
46
|
[testenv:docs-build]
|
|
51
47
|
allowlist_externals = make
|
|
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
|
{dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/dissect.cstruct.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.6.dev7 → dissect_cstruct-4.7.dev1}/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
|
|
File without changes
|