def loadPropertyFromTextFile(filename, targetproperty, targetwindow):
    try:
        with open(xbmclibrary.translatePath(filename)) as file:
            value = file.read()
        xbmclibrary.setItemToProperty(targetproperty, value, targetwindow)
    except IOError:
        xbmclibrary.writeErrorMessage(FUNCTIONNAME, FUNCTIONNAME + ' terminates: Error while reading file ' + filename)
def execute(arguments):        
    if len(arguments) > 2:
        sourcemask = arguments[2]
        targetmask = baselibrary.extractArgument(arguments, 3, DEFAULTTARGETMASK)
        targetwindow = baselibrary.extractArgument(arguments, 4, DEFAULTTARGETWINDOW)

        copyProperties(sourcemask, targetmask, targetwindow)
    else:
        xbmclibrary.writeErrorMessage(FUNCTIONNAME, FUNCTIONNAME + ' terminates: Missing argument(s) in call to script.')	
def execute(arguments):
    if len(arguments) > 2:
        filename = arguments[2]
        targetproperty = baselibrary.extractArgument(arguments, 3, DEFAULTTARGETPROPERTY)
        targetwindow = baselibrary.extractArgument(arguments, 4, DEFAULTTARGETWINDOW)

        loadPropertyFromTextFile(filename, targetproperty, targetwindow)
    else:
        xbmclibrary.writeErrorMessage(FUNCTIONNAME, FUNCTIONNAME + ' terminates: Missing filename in call to script.')	
def execute(arguments):
    if len(sys.argv) > 4:
        minimumvalue = sys.argv[2]
        maximumvalue = sys.argv[3]
        targetproperty = sys.argv[4]
        targetwindow = baselibrary.extractArgument(arguments, 5, DEFAULTTARGETWINDOW)
        
        randomvalue = randint(minimumvalue, maximumvalue)
        xbmclibrary.setItemToProperty(targetproperty, randomvalue, targetwindow)
    else:
        xbmclibrary.writeErrorMessage(FUNCTIONNAME, FUNCTIONNAME + ' terminates: Missing argument(s) in call to script.')	
def execute(arguments):
    if len(arguments) > 6:
        skinsettingmask = arguments[2]
        propertymask = arguments[3]
        index = int(arguments[4])
        otherindex = int(arguments[5])
        targetwindow = arguments[6]
        lockid = 'Lock' + str(index) + str(otherindex) + str(baselibrary.getTimeInMilliseconds())

        if setMenuOptionLocks(propertymask, targetwindow, index, otherindex, lockid):
            swapMenuSkinSettings(skinsettingmask, index, otherindex)
            swapMenuProperties(propertymask, targetwindow, index, otherindex)
            releaseMenuOptionLocks(propertymask, targetwindow, index, otherindex)
    else:
        xbmclibrary.writeErrorMessage(FUNCTIONNAME, FUNCTIONNAME + ' terminates: Missing argument(s) in call to script.')