The launcher.py which is run by Sigil in a separate process does the following:
Code:
from opf_parser import Opf_Parser
from wrapper import Wrapper
from bookcontainer import BookContainer
from inputcontainer import InputContainer
from outputcontainer import OutputContainer
from validationcontainer import ValidationContainer
So all of the bk functions for your plugin.py should already be imported and the the launcher.py does the following:
Code:
def launch(self):
script_module = self.script_module
script_type = self.script_type
container = self.container
sys.stdout = SavedStream(sys.stdout, 'stdout', self)
sys.stderr = SavedStream(sys.stderr, 'stderr', self)
try:
target_script = __import__(script_module)
self.exitcode = target_script.run(container)
sys.stdout = sys.stdout.stream
sys.stderr = sys.stderr.stream
except Exception as e:
sys.stderr.write(traceback.format_exc())
sys.stderr.write("Error: %s\n" % e)
sys.stdout = sys.stdout.stream
sys.stderr = sys.stderr.stream
self.exitcode = -1
pass
So anything you import in your plugin.py should be imported as well before its run method is invoked.
Some others can be imported since they are separate modules like compatibility_utils.py, epub_utils.py, quickparser.py, preferences.py exist and etc.