dissect.cstruct 4.6.dev2__py3-none-any.whl → 4.6.dev3__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.
@@ -226,18 +226,18 @@ class _ReadSourceGenerator:
226
226
 
227
227
  def _generate_structure(self, field: Field) -> Iterator[str]:
228
228
  template = f"""
229
- {'_s = stream.tell()' if field.type.dynamic else ''}
229
+ {"_s = stream.tell()" if field.type.dynamic else ""}
230
230
  r["{field._name}"] = {self._map_field(field)}._read(stream, context=r)
231
- {f's["{field._name}"] = stream.tell() - _s' if field.type.dynamic else ''}
231
+ {f's["{field._name}"] = stream.tell() - _s' if field.type.dynamic else ""}
232
232
  """
233
233
 
234
234
  yield dedent(template)
235
235
 
236
236
  def _generate_array(self, field: Field) -> Iterator[str]:
237
237
  template = f"""
238
- {'_s = stream.tell()' if field.type.dynamic else ''}
238
+ {"_s = stream.tell()" if field.type.dynamic else ""}
239
239
  r["{field._name}"] = {self._map_field(field)}._read(stream, context=r)
240
- {f's["{field._name}"] = stream.tell() - _s' if field.type.dynamic else ''}
240
+ {f's["{field._name}"] = stream.tell() - _s' if field.type.dynamic else ""}
241
241
  """
242
242
 
243
243
  yield dedent(template)
@@ -369,14 +369,14 @@ class cstruct:
369
369
  "null_terminated": null_terminated,
370
370
  }
371
371
 
372
- return cast(type[Array], self._make_type(name, bases, size, alignment=type_.alignment, attrs=attrs))
372
+ return cast("type[Array]", self._make_type(name, bases, size, alignment=type_.alignment, attrs=attrs))
373
373
 
374
374
  def _make_int_type(self, name: str, size: int, signed: bool, *, alignment: int | None = None) -> type[Int]:
375
- return cast(type[Int], self._make_type(name, (Int,), size, alignment=alignment, attrs={"signed": signed}))
375
+ return cast("type[Int]", self._make_type(name, (Int,), size, alignment=alignment, attrs={"signed": signed}))
376
376
 
377
377
  def _make_packed_type(self, name: str, packchar: str, base: type, *, alignment: int | None = None) -> type[Packed]:
378
378
  return cast(
379
- type[Packed],
379
+ "type[Packed]",
380
380
  self._make_type(
381
381
  name,
382
382
  (base, Packed),
@@ -141,7 +141,7 @@ class ExpressionTokenizer:
141
141
  self.tokens.append(">>")
142
142
  elif self.match(expected="<", append=False) and self.match(expected="<", append=False):
143
143
  self.tokens.append("<<")
144
- elif self.match(expected={" ", "\t"}, append=False):
144
+ elif self.match(expected={" ", "\n", "\t"}, append=False):
145
145
  continue
146
146
  else:
147
147
  raise ExpressionTokenizerError(
dissect/cstruct/parser.py CHANGED
@@ -63,7 +63,7 @@ class TokenParser(Parser):
63
63
  "ENUM",
64
64
  )
65
65
  TOK.add(r"(?<=})\s*(?P<defs>(?:[a-zA-Z0-9_]+\s*,\s*)+[a-zA-Z0-9_]+)\s*(?=;)", "DEFS")
66
- TOK.add(r"(?P<name>\**?\s*[a-zA-Z0-9_]+)(?:\s*:\s*(?P<bits>\d+))?(?:\[(?P<count>[^;\n]*)\])?\s*(?=;)", "NAME")
66
+ TOK.add(r"(?P<name>\**?\s*[a-zA-Z0-9_]+)(?:\s*:\s*(?P<bits>\d+))?(?:\[(?P<count>[^;]*)\])?\s*(?=;)", "NAME")
67
67
  TOK.add(r"#include\s+(?P<name>[^\s]+)\s*", "INCLUDE")
68
68
  TOK.add(r"[a-zA-Z_][a-zA-Z0-9_]*", "IDENTIFIER")
69
69
  TOK.add(r"[{}]", "BLOCK")
@@ -194,7 +194,7 @@ class TokenParser(Parser):
194
194
  if tokens.next == self.TOK.NAME:
195
195
  # As part of a struct field
196
196
  # struct type_name field_name;
197
- if not len(names):
197
+ if not names:
198
198
  raise ParserError(f"line {self._lineno(tokens.next)}: unexpected anonymous struct")
199
199
  return self.cstruct.resolve(names[0])
200
200
 
@@ -139,7 +139,7 @@ class StructureMetaType(MetaType):
139
139
 
140
140
  if cls.__compiled__:
141
141
  # If the previous class was compiled try to compile this too
142
- from dissect.cstruct import compiler
142
+ from dissect.cstruct import compiler # noqa: PLC0415
143
143
 
144
144
  try:
145
145
  classdict["_read"] = compiler.Compiler(cls.cs).compile_read(fields, cls.__name__, align=cls.__align__)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.cstruct
3
- Version: 4.6.dev2
3
+ Version: 4.6.dev3
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
@@ -1,10 +1,10 @@
1
1
  dissect/cstruct/__init__.py,sha256=mILXFvtajLG5EqAPSeCJ2g5klZSnRbu7uqyGcH_DF2k,1344
2
2
  dissect/cstruct/bitbuffer.py,sha256=bid_N4ZsaTeC3x5Fzs8viUrldT863dMPtEDih20Nt6k,2644
3
- dissect/cstruct/compiler.py,sha256=v1xc0E5PexaJqxyUo-tkafz2NT00hIWBLfy3iGmM7vs,14153
4
- dissect/cstruct/cstruct.py,sha256=ZVyCn23pHOvTJtPERRBSF3XBAfDKjpIf38ZYuL-nFko,19369
3
+ dissect/cstruct/compiler.py,sha256=WqkO23EE_iOpVuV7FqCFPX0Q0Mcfk0oyPacV-aCGKpk,14153
4
+ dissect/cstruct/cstruct.py,sha256=sU_gHyeBIBWP_lvCsVNARCyk8M-oItSi5MR9V9eeKBQ,19375
5
5
  dissect/cstruct/exceptions.py,sha256=WqsUW4OiIpRLQLvixfLrfKl0rtvU1qx7pvfBrz9Sz-I,293
6
- dissect/cstruct/expression.py,sha256=8UZ6M1WaQlz1uAGq0px-ScowJ0OGiz75Wl9S0HF2BGQ,10804
7
- dissect/cstruct/parser.py,sha256=IK0JfmNFUkTTUCDMcLGiLBnKWp3aN2GcT9ydutlfWb4,21322
6
+ dissect/cstruct/expression.py,sha256=KUoKxEG-KrlovIGbt_Uskjpcgafow8_sfPaBZXJo4y8,10810
7
+ dissect/cstruct/parser.py,sha256=QcNrgZU5QhmLu936kZSAYwP2w1SfQYTIRy3NAc2cXf8,21315
8
8
  dissect/cstruct/utils.py,sha256=6cU1QHTZnHXQaPoxMH93ELkwIIUgYw-TtxieEcVvYvw,10537
9
9
  dissect/cstruct/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  dissect/cstruct/tools/stubgen.py,sha256=x-jlIet9mzONfl4sbaz6fTgEJ-FXg50HqdLhFKCEJAo,7661
@@ -17,13 +17,13 @@ dissect/cstruct/types/int.py,sha256=MGsdUxJt-lj3nl9wzAgGX8cb_vJOtGLiCHwYZs1j_IA,
17
17
  dissect/cstruct/types/leb128.py,sha256=kDmsWGXX6vr1bm4uJcilsrQ7JABdQRio16rBZV21pno,2243
18
18
  dissect/cstruct/types/packed.py,sha256=tpZpb8tiSMXr1np6p0-nZqT4sY7zieO-4E16lmMmqJA,2128
19
19
  dissect/cstruct/types/pointer.py,sha256=PqeJOoNBUfMd5uO2kpF6OHeW7Q6R1N1W1V4q1MakN4I,3912
20
- dissect/cstruct/types/structure.py,sha256=TX0bFQV4p2GIJnzdaMX9UHoOHMDWfv7ouRYv2TVzm68,31761
20
+ dissect/cstruct/types/structure.py,sha256=jHiSKGJDms2qIe7-f9XEazKg6VQ9BLuwPElze3YZQBY,31778
21
21
  dissect/cstruct/types/void.py,sha256=Gvh0HqI6jQSj2uesdo3J8-G41brWCz8pmP16l8xTBxE,1074
22
22
  dissect/cstruct/types/wchar.py,sha256=N9Y_XX2_hZEe2DwepJjxsB6xuRJ6zINRalcUofR59kY,2608
23
- dissect_cstruct-4.6.dev2.dist-info/licenses/COPYRIGHT,sha256=H-18RXfshdH9AdHwW2eO1Xa-5s6tY5eipHh5c0whDu4,316
24
- dissect_cstruct-4.6.dev2.dist-info/licenses/LICENSE,sha256=PhUqiw6jAh2KbBdVRPBq_hfAvfcTBin7nZ3CK7NQbTM,11341
25
- dissect_cstruct-4.6.dev2.dist-info/METADATA,sha256=7cX0YwMcW9gyTSHiER7wX12LEHGIRN_vsxLkWGs80SE,8738
26
- dissect_cstruct-4.6.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- dissect_cstruct-4.6.dev2.dist-info/entry_points.txt,sha256=z53zqZqwD2OLrAkRwrP4wTeiU9CQe7xrMly0T2c0_wQ,71
28
- dissect_cstruct-4.6.dev2.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
29
- dissect_cstruct-4.6.dev2.dist-info/RECORD,,
23
+ dissect_cstruct-4.6.dev3.dist-info/licenses/COPYRIGHT,sha256=H-18RXfshdH9AdHwW2eO1Xa-5s6tY5eipHh5c0whDu4,316
24
+ dissect_cstruct-4.6.dev3.dist-info/licenses/LICENSE,sha256=PhUqiw6jAh2KbBdVRPBq_hfAvfcTBin7nZ3CK7NQbTM,11341
25
+ dissect_cstruct-4.6.dev3.dist-info/METADATA,sha256=dpvRYn4wTX5N2FOGqzlDGYusNxTht0ybiPvE2zgblqs,8738
26
+ dissect_cstruct-4.6.dev3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ dissect_cstruct-4.6.dev3.dist-info/entry_points.txt,sha256=z53zqZqwD2OLrAkRwrP4wTeiU9CQe7xrMly0T2c0_wQ,71
28
+ dissect_cstruct-4.6.dev3.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
29
+ dissect_cstruct-4.6.dev3.dist-info/RECORD,,