← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #233331]: No parsers found error when running from command line

 

Question #233331 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/233331

RaiMan proposed the following answer:
--- Isn't it conventional to import python modules with the file name?
Of course it is.
But that is not the question here.

Sikuli as a convenience feature allows to import other .sikuli scripts
as "modules". Together with this convenience, Sikuli adds the .sikuli
folder to the image path, so you do not need to handle the submodule
images separately.

This is implemented internally as a hook into the Jython import process.

lets make an example: 
You made submodule.sikuli, that contains some supporting functions to be used all over the place.

the usage would be e.g.
from submodule import *

This looks exactly like a normal Python import, that should find and
import a file named submodule.py from sys.path

But since we are using Sikuli to run our scripts:
- Sikuli first searches for a submodule.sikuli on sys.path. 
- then it tells the Jython import, to import the contained submodule.py
- and it adds submodule.sikuli to Sikuli's image path

If Sikuli does not find a submodule.sikuli, it delegates the further
processing to Jython import, which might or might not find a
submodule.py

In your case you did not even name a submodule like a Jython module to
import (xml), but the main script was named xml.sikuli. But since the
working folder (the folder where the script run started from) is always
on sys.path for Sikuli imports, the xml.sikuli is found first (and of
course does not contain the expected substructure) and hence hides the
wanted Jython module xml.

So a bit more precise the rule should read:
"A Sikuli script, that can be found on sys.path at runtime, should not be named as a Python module, that is to be imported in the same script run."

To avoid such clashes, I use script names like testSomefeature.sikuli,
when I want to try out a Python/Jython module somefeature.py.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.