

def defaultExpression(self, plug):
    parentNode = plug.node().ancestor(Gaffer.Node)
    if (parentNode is None):
        return ''
    if (not hasattr(plug, 'getValue')):
        return ''
    value = plug.getValue()
    objectVector = IECore.ObjectVector()
    try:
        objectVector.append(value)
    except:
        return ''

    def canExtractValue(plug, topLevelPlug, value):
        if (not len(plug)):
            return (_extractPlugValue(plug, topLevelPlug, value) is not None)
        else:
            for child in plug.children():
                if (not canExtractValue(child, topLevelPlug, value)):
                    return False
            return True
    if (not canExtractValue(plug, plug, objectVector[0])):
        return ''
    result = ''
    modulePath = Gaffer.Serialisation.modulePath(value)
    if (modulePath not in ('IECore', '')):
        result += (('import ' + modulePath) + '\n\n')
    result += 'parent["'
    result += plug.relativeName(parentNode).replace('.', '"]["')
    result += '"] = '
    result += repr(value)
    return result

dataset/ETHPy150Open ImageEngine/gaffer/python/Gaffer/PythonExpressionEngine.py PythonExpressionEngine.defaultExpression/original