fattureCCSR: added logging dialog to show action status

Signed-off-by: Ettore Dreucci <ettore.dreucci@gmail.com>
This commit is contained in:
2020-11-29 22:07:49 +01:00
parent 0f29a07614
commit d3cd8e1193
6 changed files with 196 additions and 57 deletions

16
utils.py Normal file
View 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