Add check on file existence

This commit is contained in:
Simone Gaiarin 2017-01-14 21:16:50 +01:00
parent a5c24aaca0
commit b57ee28ae7

View file

@ -488,6 +488,8 @@ class Editor(object):
def resourceToData(self, path):
"""Convert a file (specified by a path) into a data URI."""
if not os.path.exists(path):
raise FileNotFoundError
mime, _ = mimetypes.guess_type(path)
with open(path, 'rb') as fp:
data = fp.read()