T0ha / ezodf

ezodf is a Python package to create new or open existing OpenDocument (ODF) files to extract, add, modify or delete document data, forked from dead project https://bitbucket.org/mozman/ezodf
Other
61 stars 23 forks source link

Useless error message if wrong file path is given #19

Open ghost opened 8 years ago

ghost commented 8 years ago

If one calls opendoc() with a non-existing path:

opened = ezodf.opendoc("/home/user/path/that/does/not/exist.ods")

This is what one gets:

Traceback (most recent call last):
  File "/home/yyyyyyy/loop_list_test.py", line 9, in <module>
    adapted_ods = ezodf.opendoc(adapted)
  File "/usr/local/lib/python2.7/dist-packages/ezodf/document.py", line 54, in opendoc
    mime_type = __detect_mime_type(fm)
  File "/usr/local/lib/python2.7/dist-packages/ezodf/document.py", line 69, in __detect_mime_type
    mime_type = MIMETYPES[ext]
KeyError: '.ods'

It's just a suggestion but a simple check if that file actually exists and a more meaningful error message would be very helpful here.

franciscod commented 7 years ago

Got bitten by this error. I had restructured some directories and didn't notice the path wasn't right. Thanks for filing this bug!