mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
Add check on file existence
This commit is contained in:
parent
a5c24aaca0
commit
b57ee28ae7
1 changed files with 2 additions and 0 deletions
|
@ -488,6 +488,8 @@ class Editor(object):
|
||||||
|
|
||||||
def resourceToData(self, path):
|
def resourceToData(self, path):
|
||||||
"""Convert a file (specified by a path) into a data URI."""
|
"""Convert a file (specified by a path) into a data URI."""
|
||||||
|
if not os.path.exists(path):
|
||||||
|
raise FileNotFoundError
|
||||||
mime, _ = mimetypes.guess_type(path)
|
mime, _ = mimetypes.guess_type(path)
|
||||||
with open(path, 'rb') as fp:
|
with open(path, 'rb') as fp:
|
||||||
data = fp.read()
|
data = fp.read()
|
||||||
|
|
Loading…
Reference in a new issue