← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #207060]: How to pass command line argument to imported file

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Sorry for misleading - one should always test suggestions ;-)

Using Sikuli's Settings class as a replacement for global variables
(less to write and to take care for),only works within the scope of a
module (main or imported), but there over all used functions.

In your case the solution is somewhat different:

In your main module you just evaluate the command line parameter to the name of the appropriate language module
e.g.
"DE_images"

In your commons.sikuli, add a statement like this:
currLang = "EN_images" # default setting

So the import statement now has to be:
exec("import " + currLang)

If you do nothing else, then the EN version would be run.

To change the language selection dynamically in main based on the given command line parameter, you have to add the following after the import commons.sikuli:
commons.currLang = currLangFromParameter # e.g.  "DE_images"

which changes the value of currLang in commons.sikuli to what you want.

In this case finally the executed import would read
import DE_images

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