mirror of
https://github.com/Noettore/fattureCCSR.git
synced 2025-10-15 11:46:39 +02:00
fattureCCSR: added logging dialog to show action status
Signed-off-by: Ettore Dreucci <ettore.dreucci@gmail.com>
This commit is contained in:
16
utils.py
Normal file
16
utils.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""Some useful utilities"""
|
||||
|
||||
import os
|
||||
|
||||
import exc
|
||||
|
||||
def file_extension(file_path: str, allowed_ext: set = None) -> str:
|
||||
"""Return the file extension if that's in the allowed extension set"""
|
||||
if file_path in (None, ""):
|
||||
raise exc.NoFileError()
|
||||
file_ext = os.path.splitext(file_path)[1]
|
||||
if file_ext in (None, ""):
|
||||
raise exc.NoFileExtensionError
|
||||
if allowed_ext is not None and file_ext not in allowed_ext:
|
||||
raise exc.WrongFileExtensionError
|
||||
return file_ext
|
Reference in New Issue
Block a user