← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #252800]: changes from True to False

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Then this is the most flexible solution:

step 1: read the current content of Instructions to the dictionary 
step 2: modify the dictionary as needed
step 3: write the dictionary back to Instructions.txt

def getInstructions(inp):
    store = {}
    configInput = open(inp)
    for line in configInput.readlines():
        (key, val) = line.strip().split("=")
        config[key.strip()] = val.strip()
    configInput.close()
    return store    

def putInstructions(out, store):
    configOutput = open(out, "w")
    for key in store.keys():
        line = key + "=" + store[key] + "\n"
        out.write(line)
    configInput.close()

# step 1: fetch current instructions 
instructions = getInstructions("C:\\Users\\Richi\\Desktop\\Instructions.txt")

# step 2: modify instructions
instructions["data.configure.camera"] = "false"

# one might add additional instructions
instructions["data.configure.newoption"] = "true"

# step 3: write the instructions back to file
putInstructions("C:\\Users\\Richi\\Desktop\\Instructions.txt", instructions)

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