From ffbf4f83169d5c6db2448d42c0e2fa5cec5c874a Mon Sep 17 00:00:00 2001 From: Erik Schamper <1254028+Schamper@users.noreply.github.com> Date: Fri, 24 Nov 2023 12:01:52 +0100 Subject: [PATCH] Return self on load for chaining (#53) --- dissect/cstruct/cstruct.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dissect/cstruct/cstruct.py b/dissect/cstruct/cstruct.py index eab420d..605fac7 100644 --- a/dissect/cstruct/cstruct.py +++ b/dissect/cstruct/cstruct.py @@ -188,7 +188,7 @@ def addtype(self, name: str, type_: BaseType, replace: bool = False) -> None: self.typedefs[name] = type_ - def load(self, definition: str, deftype: int = None, **kwargs) -> None: + def load(self, definition: str, deftype: int = None, **kwargs) -> "cstruct": """Parse structures from the given definitions using the given definition type. Definitions can be parsed using different parsers. Currently, there's @@ -212,6 +212,8 @@ def load(self, definition: str, deftype: int = None, **kwargs) -> None: elif deftype == cstruct.DEF_LEGACY: CStyleParser(self, **kwargs).parse(definition) + return self + def loadfile(self, path: str, deftype: int = None, **kwargs) -> None: """Load structure definitions from a file.