From 76525516ed53582266dbf2578e192edcad26f7db Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:35:13 +0000 Subject: [PATCH 1/3] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.2.2 → v0.3.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.2.2...v0.3.5) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf7f50f8..cc065753 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.2.2 + rev: v0.3.5 hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] \ No newline at end of file From 1ffcb9b3f1e92ccbb1cf998aa8dafdfbe285e77a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 22:35:20 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/mercury_engine_data_structures/common_types.py | 6 +----- .../construct_extensions/function_complex.py | 4 +--- tools/create_class_definitions.py | 6 +----- tools/ghidra_export.py | 5 +---- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/mercury_engine_data_structures/common_types.py b/src/mercury_engine_data_structures/common_types.py index 95bb6b5d..77d5e07f 100644 --- a/src/mercury_engine_data_structures/common_types.py +++ b/src/mercury_engine_data_structures/common_types.py @@ -276,11 +276,7 @@ def _build(self, obj: construct.Container, stream, context, path): self.value_type._build(value, stream, context, field_path) def _emitparse(self, code): - return "Container(({}, {}) for i in range({}))".format( - self.key_type._compileparse(code), - self.value_type._compileparse(code), - self.count_type._compileparse(code), - ) + return f"Container(({self.key_type._compileparse(code)}, {self.value_type._compileparse(code)}) for i in range({self.count_type._compileparse(code)}))" def _emitbuild(self, code): fname = f"build_dict_{code.allocateId()}" diff --git a/src/mercury_engine_data_structures/construct_extensions/function_complex.py b/src/mercury_engine_data_structures/construct_extensions/function_complex.py index 69f55a43..7bed8cd1 100644 --- a/src/mercury_engine_data_structures/construct_extensions/function_complex.py +++ b/src/mercury_engine_data_structures/construct_extensions/function_complex.py @@ -107,9 +107,7 @@ def _insert_cond(self, code: construct.CodeGen): return f"linkedinstances[{id(self.condfunc)}](this)" def _emitparse(self, code): - return "(({}) if ({}) else ({}))".format(self.thensubcon._compileparse(code), - self._insert_cond(code), - self.elsesubcon._compileparse(code), ) + return f"(({self.thensubcon._compileparse(code)}) if ({self._insert_cond(code)}) else ({self.elsesubcon._compileparse(code)}))" def _emitbuild(self, code): return (f"(({self.thensubcon._compilebuild(code)}) if (" diff --git a/tools/create_class_definitions.py b/tools/create_class_definitions.py index 6fd1b1ce..35d56538 100644 --- a/tools/create_class_definitions.py +++ b/tools/create_class_definitions.py @@ -197,11 +197,7 @@ def export_code(self): for type_name in sorted(self._types_with_pointer): if type_name != "base::reflection::CTypedValue": - code += '{}.add_option("{}", {})\n'.format( - self.pointer_to_type(type_name), - type_name, - self.ensure_exported_type(type_name), - ) + code += f'{self.pointer_to_type(type_name)}.add_option("{type_name}", {self.ensure_exported_type(type_name)})\n' for child in sorted(self.children_for(type_name)): code += f'{self.pointer_to_type(type_name)}.add_option("{child}", {self.ensure_exported_type(child)})\n' code += "\n" diff --git a/tools/ghidra_export.py b/tools/ghidra_export.py index 27548b96..c636c084 100644 --- a/tools/ghidra_export.py +++ b/tools/ghidra_export.py @@ -661,10 +661,7 @@ def _merge_split_types(final_results: dict[str, typing.Any]): both_hash = key in hashes and similar[0] in hashes if both_hash: - print("{} (Hash: {}) is similar to {} (Hash: {})".format( - key, key in dread_data.all_name_to_property_id(), - similar[0], similar[0] in dread_data.all_name_to_property_id(), - )) + print(f"{key} (Hash: {key in dread_data.all_name_to_property_id()}) is similar to {similar[0]} (Hash: {similar[0] in dread_data.all_name_to_property_id()})") elif key in hashes: wrong_to_correct[similar[0]] = key elif similar[0] in hashes: From 2e5972bdfa890cbf67230f16148472cc139b7bcb Mon Sep 17 00:00:00 2001 From: Thanatos Date: Sun, 7 Apr 2024 21:13:45 +0200 Subject: [PATCH 3/3] Fix long lines --- src/mercury_engine_data_structures/common_types.py | 5 ++++- .../construct_extensions/function_complex.py | 5 ++++- tools/create_class_definitions.py | 5 ++++- tools/ghidra_export.py | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mercury_engine_data_structures/common_types.py b/src/mercury_engine_data_structures/common_types.py index 77d5e07f..b31799fb 100644 --- a/src/mercury_engine_data_structures/common_types.py +++ b/src/mercury_engine_data_structures/common_types.py @@ -276,7 +276,10 @@ def _build(self, obj: construct.Container, stream, context, path): self.value_type._build(value, stream, context, field_path) def _emitparse(self, code): - return f"Container(({self.key_type._compileparse(code)}, {self.value_type._compileparse(code)}) for i in range({self.count_type._compileparse(code)}))" + return ( + f"Container(({self.key_type._compileparse(code)}, {self.value_type._compileparse(code)}) " + f"for i in range({self.count_type._compileparse(code)}))" + ) def _emitbuild(self, code): fname = f"build_dict_{code.allocateId()}" diff --git a/src/mercury_engine_data_structures/construct_extensions/function_complex.py b/src/mercury_engine_data_structures/construct_extensions/function_complex.py index 7bed8cd1..a6bf71bf 100644 --- a/src/mercury_engine_data_structures/construct_extensions/function_complex.py +++ b/src/mercury_engine_data_structures/construct_extensions/function_complex.py @@ -107,7 +107,10 @@ def _insert_cond(self, code: construct.CodeGen): return f"linkedinstances[{id(self.condfunc)}](this)" def _emitparse(self, code): - return f"(({self.thensubcon._compileparse(code)}) if ({self._insert_cond(code)}) else ({self.elsesubcon._compileparse(code)}))" + return ( + f"(({self.thensubcon._compileparse(code)}) if ({self._insert_cond(code)}) " + f"else ({self.elsesubcon._compileparse(code)}))" + ) def _emitbuild(self, code): return (f"(({self.thensubcon._compilebuild(code)}) if (" diff --git a/tools/create_class_definitions.py b/tools/create_class_definitions.py index 35d56538..90a1ce9a 100644 --- a/tools/create_class_definitions.py +++ b/tools/create_class_definitions.py @@ -197,7 +197,10 @@ def export_code(self): for type_name in sorted(self._types_with_pointer): if type_name != "base::reflection::CTypedValue": - code += f'{self.pointer_to_type(type_name)}.add_option("{type_name}", {self.ensure_exported_type(type_name)})\n' + code += ( + f'{self.pointer_to_type(type_name)}.add_option("{type_name}", ' + f'{self.ensure_exported_type(type_name)})\n' + ) for child in sorted(self.children_for(type_name)): code += f'{self.pointer_to_type(type_name)}.add_option("{child}", {self.ensure_exported_type(child)})\n' code += "\n" diff --git a/tools/ghidra_export.py b/tools/ghidra_export.py index c636c084..b3517204 100644 --- a/tools/ghidra_export.py +++ b/tools/ghidra_export.py @@ -661,7 +661,10 @@ def _merge_split_types(final_results: dict[str, typing.Any]): both_hash = key in hashes and similar[0] in hashes if both_hash: - print(f"{key} (Hash: {key in dread_data.all_name_to_property_id()}) is similar to {similar[0]} (Hash: {similar[0] in dread_data.all_name_to_property_id()})") + print( + f"{key} (Hash: {key in dread_data.all_name_to_property_id()}) is similar to " + f"{similar[0]} (Hash: {similar[0] in dread_data.all_name_to_property_id()})" + ) elif key in hashes: wrong_to_correct[similar[0]] = key elif similar[0] in hashes: