@@ -213,31 +213,31 @@ def make_zim_file(
213213 zim_file .finish ()
214214
215215
216- class BadZimfileDataError (Exception ):
216+ class IncorrectZIMPathError (Exception ):
217217 """A generic exception for any problem encountered in validate_zimfile_creatable"""
218218
219219 pass
220220
221221
222- class ZimFolderNotFoundError ( BadZimfileDataError ):
222+ class MissingZIMFolderError ( IncorrectZIMPathError ):
223223 """Exception raised in validate_zimfile_creatable when folder does not exists"""
224224
225225 pass
226226
227227
228- class BadZimFolderError ( BadZimfileDataError ):
228+ class NotADirectoryZIMFolderError ( IncorrectZIMPathError ):
229229 """Exception raised in validate_zimfile_creatable when folder is not a directory"""
230230
231231 pass
232232
233233
234- class ZimFolderNotWritableError ( BadZimfileDataError ):
234+ class NotWritableZIMFolderError ( IncorrectZIMPathError ):
235235 """Exception raised in validate_zimfile_creatable when folder is not writable"""
236236
237237 pass
238238
239239
240- class BadZimFilenameError ( BadZimfileDataError ):
240+ class IncorrectZIMFilenameError ( IncorrectZIMPathError ):
241241 """
242242 Exception raised in validate_zimfile_creatable when filename is not creatable
243243
@@ -251,27 +251,27 @@ class BadZimFilenameError(BadZimfileDataError):
251251def validate_zimfile_creatable (folder : str | pathlib .Path , filename : str ):
252252 """Validate that a ZIM can be created in given folder with given filename
253253
254- Any problem encountered raises an exception inheriting from BadZimfileDataError
254+ Any problem encountered raises an exception inheriting from IncorrectZIMPathError
255255
256256 Checks that:
257- - folder passed exists (or raise ZimFolderNotFoundError exception)
258- - folder passed is a directory (or raise BadZimFolderError exception)
257+ - folder passed exists (or raise MissingZIMFolderError exception)
258+ - folder passed is a directory (or raise NotADirectoryZIMFolderError exception)
259259 - folder is writable, i.e. it is possible to create a file in folder (or raise
260- ZimFolderNotWritableError exception with inner exception details)
260+ NotWritableZIMFolderError exception with inner exception details)
261261 - filename is creatable, i.e. there is no bad characters in filename (or raise
262- BadZimFilenameError exception with inner exception details)
262+ IncorrectZIMFilenameError exception with inner exception details)
263263 """
264264 folder = pathlib .Path (folder )
265265
266266 # ensure folder exists
267267 if not folder .exists ():
268- raise ZimFolderNotFoundError (
268+ raise MissingZIMFolderError (
269269 f"Folder to create the ZIM does not exist: { folder } "
270270 )
271271
272272 # ensure folder is a directory
273273 if not folder .is_dir ():
274- raise BadZimFolderError (
274+ raise NotADirectoryZIMFolderError (
275275 f"Folder to create the ZIM is not a directory: { folder } "
276276 )
277277
@@ -281,16 +281,18 @@ def validate_zimfile_creatable(folder: str | pathlib.Path, filename: str):
281281 # ensure folder is writable
282282 with tempfile .NamedTemporaryFile (dir = folder , delete = True ) as fh :
283283 logger .debug (f"Output is writable. Temporary file used for test: { fh .name } " )
284- except Exception as e :
285- raise ZimFolderNotWritableError (
284+ except Exception as exc :
285+ raise NotWritableZIMFolderError (
286286 f"Folder to create the ZIM is not writable: { folder } "
287- ) from e
287+ ) from exc
288288
289289 # ensure ZIM file is creatable with the given name
290- file_path = folder / filename
290+ fpath = folder / filename
291291 try :
292- logger .debug (f"Confirming ZIM file can be created at { file_path } " )
293- file_path .touch ()
294- file_path .unlink ()
295- except Exception as e :
296- raise BadZimFilenameError (f"ZIM filename is not creatable: { file_path } " ) from e
292+ logger .debug (f"Confirming ZIM file can be created at { fpath } " )
293+ fpath .touch ()
294+ fpath .unlink ()
295+ except Exception as exc :
296+ raise IncorrectZIMFilenameError (
297+ f"ZIM filename is not creatable: { fpath } "
298+ ) from exc
0 commit comments