Skip to content

Commit

Permalink
models.file:MasterFile.identify - use separate method to identify fil…
Browse files Browse the repository at this point in the history
…e with Siegfried and assign actions
  • Loading branch information
MatteoCampinoti94 committed Nov 27, 2024
1 parent 0bc027f commit 58615e8
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions acacore/models/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,16 +495,29 @@ def from_file(
processed=processed,
)

file.identify(siegfried, custom_signatures, actions)

return file

def identify(
self,
siegfried: Siegfried | SiegfriedFile | None = None,
custom_signatures: list[CustomSignature] | None = None,
actions: dict[str, MasterConvertAction] | None = None,
):
if not siegfried and not custom_signatures:
return

file_classes: list[TSiegfriedFileClass] = []

if isinstance(siegfried, SiegfriedFile) and siegfried.matches:
file_classes = siegfried.best_match().file_classes
if siegfried and (match := super().identify(siegfried, set_match=True).best_match()):
file_classes = match.match_class
elif custom_signatures:
self.identify_custom(custom_signatures, set_match=True)

if actions:
file.get_action("access", actions, file_classes, set_match=True)
file.get_action("statutory", actions, file_classes, set_match=True)

return file
self.get_action("access", actions, file_classes, set_match=True)
self.get_action("statutory", actions, file_classes, set_match=True)

def get_action(
self,
Expand Down

0 comments on commit 58615e8

Please sign in to comment.