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.
|