View Single Post
Old 01-11-2021, 03:10 AM   #12
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,424
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It's a calibre specific function defined globally. Just use it as is, it will always return the path to the specified file. If you want to see its implementation look in utils/resources.py in the calibre code.

Yes, if you return from inside with, __exit__ is called before the function returns. As for where to call __enter__ call it in load_actual_plugin, and there's no need to call __exit__, since it will be cleaned up automatically on process exit. However, I recommend monkey-patching over this, since this approach affects global state, and therefore all other code running in the same process.
kovidgoyal is offline   Reply With Quote