From 3dd22f40996fc128ffce6026e8e747ca66bcc21d Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Mon, 22 Jan 2024 16:11:19 -0500 Subject: Project support --- python/filemetadata.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'python/filemetadata.py') diff --git a/python/filemetadata.py b/python/filemetadata.py index ec0e16bb..e51436b1 100644 --- a/python/filemetadata.py +++ b/python/filemetadata.py @@ -31,6 +31,7 @@ from .log import log_error from . import binaryview from . import database from . import deprecation +from . import project ProgressFuncType = Callable[[int, int], bool] ViewName = str @@ -298,6 +299,20 @@ class FileMetadata: def snapshot_data_applied_without_error(self) -> bool: return core.BNIsSnapshotDataAppliedWithoutError(self.handle) + @property + def project(self) -> Optional['project.Project']: + project_file = self.project_file + if project_file is None: + return None + return project_file.project + + @property + def project_file(self) -> Optional['project.ProjectFile']: + handle = core.BNGetProjectFile(self.handle) + if handle is None: + return None + return project.ProjectFile(handle) + def close(self) -> None: """ Closes the underlying file handle. It is recommended that this is done in a @@ -606,14 +621,6 @@ class FileMetadata: return None return binaryview.BinaryView(file_metadata=self, handle=view) - def open_project(self) -> bool: - return core.BNOpenProject(self.handle) - - def close_project(self) -> None: - core.BNCloseProject(self.handle) - - def is_project_open(self) -> bool: - return core.BNIsProjectOpen(self.handle) @property def existing_views(self) -> List[ViewName]: -- cgit v1.3.1