← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #210973]: Sikuli code organization / code reuse

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--1. do not use folder names .sikuli ...
... if they do not contain a Sikuli script and its resources
Because this collides with the internal import support for .sikuli , which will import the contained .py and add the folder .sikuli to the image path automagically by only using (for a sub.sikuli)
import sub

--2. in a flat organization ...
... where all .sikuli files are in one folder, there is no need for sys.path manipulation.
just saying 
import sub
will find the sub.sikuli in the same folder as the importing .sikuli resides.

--3. in a rather fixed substructure ...
you can use one support script, that you import using
from support import *
and delegate the rest  to the script support.sikuli
(this is why from sikuli import * reveals all Sikuli features)

--4. in a living structure ...
... use a naming convention for the scripts and scan the subtree in support.sikuli and use 
exec"import "+evaluated_script_name
then 
from support import *
can still be used 

--5. location for bootstrap scripts 
If you have those generally supporting scripts, that you want to import all around the place, put them into a folder named "Lib" (you might have to create it), in the same folder as sikuli-script.jar resides.
This folder is in sys.path per default (a Jython convention).

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