File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 99
1010import logging
1111import traceback
12+ import zipfile
1213
1314from collections import namedtuple
1415from functools import partial
@@ -229,14 +230,15 @@ def extract_files(
229230 if TRACE :
230231 logger .debug ('extract:walk:recurse:extraction event: %(xevent)r' % locals ())
231232 yield xevent
232-
233+
233234def extract_libre_office_document (location , target ):
234- """ Extract Libre Office documents (e.g., .ods files) as ZIP archives. """
235- if not zipfile .is_zipfile (location ):
236- return
237- with zipfile .ZipFile (location , 'r' ) as zip_ref :
238- zip_ref .extractall (target )
239- print (f"Extracted Libre Office document from { location } to { target } " )
235+ """Extract Libre Office documents (e.g., .ods files) as ZIP archives."""
236+ try :
237+ with zipfile .ZipFile (location , 'r' ) as zip_ref :
238+ zip_ref .extractall (target )
239+ logger .info (f"Extracted Libre Office document from { location } to { target } " )
240+ except zipfile .BadZipFile :
241+ raise ValueError (f"File at { location } is not a valid ZIP archive." )
240242
241243
242244def extract_file (
You can’t perform that action at this time.
0 commit comments