@@ -103,7 +103,7 @@ class ValidChunk(Chunk):
103103 handler : "Handler" = attr .ib (init = False , eq = False )
104104 is_encrypted : bool = attr .ib (default = False )
105105
106- def extract (self , inpath : Path , outdir : Path ):
106+ def extract (self , inpath : Path , outdir : Path ) -> Optional [ "ExtractResult" ] :
107107 if self .is_encrypted :
108108 logger .warning (
109109 "Encrypted file is not extracted" ,
@@ -112,7 +112,7 @@ def extract(self, inpath: Path, outdir: Path):
112112 )
113113 raise ExtractError
114114
115- self .handler .extract (inpath , outdir )
115+ return self .handler .extract (inpath , outdir )
116116
117117 def as_report (self , extraction_reports : List [Report ]) -> ChunkReport :
118118 return ChunkReport (
@@ -154,8 +154,8 @@ class MultiFile(Blob):
154154
155155 handler : "DirectoryHandler" = attr .ib (init = False , eq = False )
156156
157- def extract (self , outdir : Path ):
158- self .handler .extract (self .paths , outdir )
157+ def extract (self , outdir : Path ) -> Optional [ "ExtractResult" ] :
158+ return self .handler .extract (self .paths , outdir )
159159
160160 def as_report (self , extraction_reports : List [Report ]) -> MultiFileReport :
161161 return MultiFileReport (
@@ -253,13 +253,18 @@ def __init__(self, *reports: Report):
253253 self .reports : Tuple [Report , ...] = reports
254254
255255
256+ @attr .define (kw_only = True )
257+ class ExtractResult :
258+ reports : List [Report ]
259+
260+
256261class Extractor (abc .ABC ):
257262 def get_dependencies (self ) -> List [str ]:
258263 """Return the external command dependencies."""
259264 return []
260265
261266 @abc .abstractmethod
262- def extract (self , inpath : Path , outdir : Path ):
267+ def extract (self , inpath : Path , outdir : Path ) -> Optional [ ExtractResult ] :
263268 """Extract the carved out chunk.
264269
265270 Raises ExtractError on failure.
@@ -272,7 +277,7 @@ def get_dependencies(self) -> List[str]:
272277 return []
273278
274279 @abc .abstractmethod
275- def extract (self , paths : List [Path ], outdir : Path ):
280+ def extract (self , paths : List [Path ], outdir : Path ) -> Optional [ ExtractResult ] :
276281 """Extract from a multi file path list.
277282
278283 Raises ExtractError on failure.
@@ -381,15 +386,15 @@ def get_dependencies(cls):
381386 def calculate_multifile (self , file : Path ) -> Optional [MultiFile ]:
382387 """Calculate the MultiFile in a directory, using a file matched by the pattern as a starting point."""
383388
384- def extract (self , paths : List [Path ], outdir : Path ):
389+ def extract (self , paths : List [Path ], outdir : Path ) -> Optional [ ExtractResult ] :
385390 if self .EXTRACTOR is None :
386391 logger .debug ("Skipping file: no extractor." , paths = paths )
387392 raise ExtractError
388393
389394 # We only extract every blob once, it's a mistake to extract the same blob again
390395 outdir .mkdir (parents = True , exist_ok = False )
391396
392- self .EXTRACTOR .extract (paths , outdir )
397+ return self .EXTRACTOR .extract (paths , outdir )
393398
394399
395400class Handler (abc .ABC ):
@@ -414,15 +419,15 @@ def get_dependencies(cls):
414419 def calculate_chunk (self , file : File , start_offset : int ) -> Optional [ValidChunk ]:
415420 """Calculate the Chunk offsets from the File and the file type headers."""
416421
417- def extract (self , inpath : Path , outdir : Path ):
422+ def extract (self , inpath : Path , outdir : Path ) -> Optional [ ExtractResult ] :
418423 if self .EXTRACTOR is None :
419424 logger .debug ("Skipping file: no extractor." , path = inpath )
420425 raise ExtractError
421426
422427 # We only extract every blob once, it's a mistake to extract the same blob again
423428 outdir .mkdir (parents = True , exist_ok = False )
424429
425- self .EXTRACTOR .extract (inpath , outdir )
430+ return self .EXTRACTOR .extract (inpath , outdir )
426431
427432
428433class StructHandler (Handler ):
0 commit comments