sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #22006
Re: [Question #238023]: append feature- html
Question #238023 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/238023
Status: Open => Answered
RaiMan proposed the following answer:
--1. depending on Sikuli version:
do not have .sikuli at the drive's top level, always use at least one folder level
--2. do not put other stuff into .sikuli folders,
... this might be deleted without notice
--3. .sikuli in the same folder will be found by import
--4. code in imported .sikuli on indent level 0 is executed at import,
but only once (not on rerun in IDE)
-- recommended folder structure:
-- c:\scripts
callingfun.sikuli
calledfun.sikuli
# content of callingfun.sikuli
import calledfun
reload(calledfun)
testName = 'C:\\test1.html'
test=open(testName,'w')
test.writelines("heyya")
calledfun.append(testName, "wassup")
test.close()
# content of calledfun.sikuli
from sikuli import *
def append(fname, text)
f = open(fame, "a")
f.writelines(text)
f.close()
--- comment on reload
In Sikuli IDE you should always use functions in imported .sikuli (no code on indent level 0, that cannot be repeated.
when using reload(), the .sikuli will be reimported,so changes are reflected on rerun, which means you can work on both scripts in parallel in IDE. Using the auto-save-on-run option with version 1.0.1 youwill always run the latest script content.
BTW: good post to understand writelines()
http://stackoverflow.com/questions/12377473/python-write-versus-writelines-and-concatenated-strings
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.