sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #24369
Re: [Question #243323]: How To import a .skl file --- workaround
Question #243323 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/243323
RaiMan posted a new comment:
ok, a bug in the code ;-) sorry
# get Sikuli’s Filemanager class
import org.sikuli.basics.FileManager as SFm
import os
# get the folderpath the main script is stored
scriptPath = os.path.join(os.path.dirname(os.path.dirname(getBundlePath())))
# get the folder path of a ….skl stored in the same folder (here sub.skl)
sub = os.path.join(scriptPath, "sub.skl“)
# unzip to temp folder (the only option here ;-)
subPath = SFm.unzipSKL(sub)
# put it on sys.path
sys.path.append(os.path.dirname(subPath))
# import it
import <submodule name>
# use it
….
# before exit delete it
SFm.deleteFileOrFolder(subPath)
There are 2 "variables" that have to be adapted to your situation:
- "sub.skl" has to be the file name os your .skl to be imported.
- <submodule name> has to be the name of the module to be imported
example:
- you had a mystuff.sikuli, that you exported as mystuff.skl
the instead of "sub.skl" you have to use
"mystuff.skl"
and instead of <submodule name> you have to use
mystuff
again the relevant part:
...
sub = os.path.join(scriptPath, "mystuff.skl“)
# unzip to temp folder (the only option here ;-)
subPath = SFm.unzipSKL(sub)
# put it on sys.path
sys.path.append(os.path.dirname(subPath))
# import it
import mystuff
...
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.