From dc0988214c3b6f0c12f97a7f39b7ca672c6cd4a3 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Mon, 6 Nov 2023 14:53:08 +0100 Subject: [PATCH] models:file - allow to set UUID in File.from_file --- acacore/models/file.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/acacore/models/file.py b/acacore/models/file.py index db395ba..2bbe8c3 100644 --- a/acacore/models/file.py +++ b/acacore/models/file.py @@ -59,6 +59,8 @@ def from_file( siegfried: Optional[Siegfried] = None, actions: Optional[dict[str, Action]] = None, custom_signatures: Optional[list[CustomSignature]] = None, + *, + uuid: Optional[UUID4] = None, ): """ Create a File object from a given file. @@ -75,11 +77,13 @@ def from_file( siegfried: A Siegfried class object to identify the file. actions: A dictionary with PUID keys and Action values to assign an action. custom_signatures: A list of CustomSignature objects to refine the identification. + uuid: Optionally, a specific UUID to use for the file. Returns: File: A File object. """ file = cls( + uuid=uuid or uuid4(), checksum=file_checksum(path), puid=None, relative_path=path.relative_to(root) if root else path,