Skip to content

Commit

Permalink
siegfried - format
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Oct 16, 2023
1 parent 603f74c commit 105291e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions acacore/siegfried/siegfried.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from subprocess import run

from pydantic import BaseModel
from pydantic import ConfigDict
from pydantic import Field
from pydantic import field_validator, ConfigDict
from pydantic import field_validator

from acacore.exceptions.files import IdentificationError

Expand All @@ -17,9 +18,8 @@ def _check_process(process: CompletedProcess):
"""
if process.returncode != 0:
raise IdentificationError(
process.stderr or
process.stdout or
f"Unknown siegfried error code {process.returncode}")
process.stderr or process.stdout or f"Unknown siegfried error code {process.returncode}"
)


class SiegfriedIdentifier(BaseModel):
Expand Down Expand Up @@ -95,8 +95,11 @@ def identify(self, path: str | PathLike) -> SiegfriedResult:
Raises:
IdentificationError: if there is an error calling Siegfried or processing its results
"""
process: CompletedProcess = run([self.binary, "-json", "-multi", "1024", str(path)],
capture_output=True, encoding="utf-8")
process: CompletedProcess = run(
[self.binary, "-json", "-multi", "1024", str(path)],
capture_output=True,
encoding="utf-8",
)
_check_process(process)
try:
return SiegfriedResult.model_validate_json(process.stdout)
Expand Down

0 comments on commit 105291e

Please sign in to comment.