New issue 418: guess_file_type raises error instead of None if python-magic is 
not installed.

https://bitbucket.org/blais/beancount/issues/418/guess_file_type-raises-error-instead-of



cevans:



Documentation for `guess_file_type` notes that it will return `None` if it 
can’t guess the file’s type.  However, if python-magic is not available, and it 
can’t recognize a file, it raises a `ValueError`. This isn’t necessarily 
desirable: `mimetypes` may sufficiently recognize all the file types the user 
wants to recognize, but files that the user doesn’t care about positively 
recognizing through `guess_file_type` will break importers for other files that 
use it.



In my use case, I have many files that are easily recognized by `mimetypes` 
\(pdf, csv\), but one importer that uses something else \(asp…\).  The importer 
using that doesn’t rely on `guess_file_type` for identification, other 
importers that do break when there is an asp file there and they try to 
identify it \(eg, when using fava\).



The function already uses warnings, so it would make sense to replace the error 
with a warning, and return `None` if the file has not already been recognized 
and python-magic is not available.




-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/20200207132614.14674.45387%40celery-worker-112.ash1.bb-inf.net.

Reply via email to