@@ -220,33 +220,33 @@ def make_zim_file(
220220 zim_file .finish ()
221221
222222
223- class IncorrectZIMPathError (Exception ):
224- """A generic exception for any problem encountered in validate_zimfile_creatable """
223+ class IncorrectPathError (Exception ):
224+ """A generic exception for any problem encountered while working with filepaths """
225225
226226 pass
227227
228228
229- class MissingZIMFolderError ( IncorrectZIMPathError ):
230- """Exception raised in validate_zimfile_creatable when folder does not exists """
229+ class MissingFolderError ( IncorrectPathError ):
230+ """Exception raised when folder does not exist """
231231
232232 pass
233233
234234
235- class NotADirectoryZIMFolderError ( IncorrectZIMPathError ):
236- """Exception raised in validate_zimfile_creatable when folder is not a directory"""
235+ class NotADirectoryFolderError ( IncorrectPathError ):
236+ """Exception raised when folder is not a directory"""
237237
238238 pass
239239
240240
241- class NotWritableZIMFolderError ( IncorrectZIMPathError ):
242- """Exception raised in validate_zimfile_creatable when folder is not writable"""
241+ class NotWritableFolderError ( IncorrectPathError ):
242+ """Exception raised when folder is not writable"""
243243
244244 pass
245245
246246
247- class IncorrectZIMFilenameError ( IncorrectZIMPathError ):
247+ class IncorrectFilenameError ( IncorrectPathError ):
248248 """
249- Exception raised in validate_zimfile_creatable when filename is not creatable
249+ Exception raised when filename is not creatable
250250
251251 This usually occurs when bad characters are present in filename (typically
252252 characters not supported on current filesystem).
@@ -258,21 +258,21 @@ class IncorrectZIMFilenameError(IncorrectZIMPathError):
258258def validate_folder_writable (folder : pathlib .Path ):
259259 """Validate that a file can be created in a given folder.
260260
261- Any problem encountered raises an exception inheriting from IncorrectZIMPathError
261+ Any problem encountered raises an exception inheriting from IncorrectPathError
262262
263263 Checks that:
264- - folder passed exists (or raise MissingZIMFolderError exception)
265- - folder passed is a directory (or raise NotADirectoryZIMFolderError exception)
264+ - folder passed exists (or raise MissingFolderError exception)
265+ - folder passed is a directory (or raise NotADirectoryFolderError exception)
266266 - folder is writable, i.e. it is possible to create a file in folder (or raise
267- NotWritableZIMFolderError exception with inner exception details)
267+ NotWritableFolderError exception with inner exception details)
268268 """
269269 # ensure folder exists
270270 if not folder .exists ():
271- raise MissingZIMFolderError (f"Folder does not exist: { folder } " )
271+ raise MissingFolderError (f"Folder does not exist: { folder } " )
272272
273273 # ensure folder is a directory
274274 if not folder .is_dir ():
275- raise NotADirectoryZIMFolderError (f"Folder is not a directory: { folder } " )
275+ raise NotADirectoryFolderError (f"Folder is not a directory: { folder } " )
276276
277277 logger .debug (f"Attempting to confirm output is writable in directory { folder } " )
278278
@@ -281,17 +281,17 @@ def validate_folder_writable(folder: pathlib.Path):
281281 with tempfile .NamedTemporaryFile (dir = folder , delete = True ) as fh :
282282 logger .debug (f"Output is writable. Temporary file used for test: { fh .name } " )
283283 except Exception as exc :
284- raise NotWritableZIMFolderError (f"Folder is not writable: { folder } " ) from exc
284+ raise NotWritableFolderError (f"Folder is not writable: { folder } " ) from exc
285285
286286
287287def validate_file_creatable (folder : str | pathlib .Path , filename : str ):
288288 """Validate that a file can be created in given folder with given filename
289289
290- Any problem encountered raises an exception inheriting from IncorrectZIMPathError
290+ Any problem encountered raises an exception inheriting from IncorrectPathError
291291
292292 Checks that:
293293 - folder is writable (or raise exception from `validate_folder_writable`)
294- - file can be created (or raise IncorrectZIMFilenameError exception with
294+ - file can be created (or raise IncorrectFilenameError exception with
295295 inner exception details)
296296 """
297297 folder = pathlib .Path (folder )
@@ -305,21 +305,21 @@ def validate_file_creatable(folder: str | pathlib.Path, filename: str):
305305 fpath .touch ()
306306 fpath .unlink ()
307307 except Exception as exc :
308- raise IncorrectZIMFilenameError (f"File is not creatable: { fpath } " ) from exc
308+ raise IncorrectFilenameError (f"File is not creatable: { fpath } " ) from exc
309309
310310
311311def validate_zimfile_creatable (folder : str | pathlib .Path , filename : str ):
312312 """Validate that a ZIM can be created in given folder with given filename
313313
314- Any problem encountered raises an exception inheriting from IncorrectZIMPathError
314+ Any problem encountered raises an exception inheriting from IncorrectPathError
315315
316316 Checks that:
317- - folder passed exists (or raise MissingZIMFolderError exception)
318- - folder passed is a directory (or raise NotADirectoryZIMFolderError exception)
317+ - folder passed exists (or raise MissingFolderError exception)
318+ - folder passed is a directory (or raise NotADirectoryFolderError exception)
319319 - folder is writable, i.e. it is possible to create a file in folder (or raise
320- NotWritableZIMFolderError exception with inner exception details)
320+ NotWritableFolderError exception with inner exception details)
321321 - filename is creatable, i.e. there is no bad characters in filename (or raise
322- IncorrectZIMFilenameError exception with inner exception details)
322+ IncorrectFilenameError exception with inner exception details)
323323 """
324324 warnings .warn (
325325 "'validate_zimfile_creatable' is deprecated and will be removed. "
0 commit comments