How to create a Cycles material with python to bake a curvature map
zero025 helped me to code it:

import bpy

#Generate the textures and shader
#################################
#Get texture in data-block
###########################
tex = bpy.data.images.get("curvature")


#If exist or not
#################
if  tex is None:
    #create texture in data block
    tex = bpy.data.images.new("curvature", width=size[0], height=size[1], alpha = True)


    #Create material nodes "CURVATURE"
    ################################################################

    # Test if material exists
    # If it does not exist, create it:
    mat = bpy.data.materials.get("CURVATURE")

    if  mat is None:
       mat = bpy.data.materials.new("CURVATURE")

       # Enable 'Use nodes':
       mat.use_nodes = True
       nt = mat.node_tree
       nodes = nt.nodes
       links = nt.links

       # clear
       while(nodes): nodes.remove(nodes[0])

       d_geometry  = nodes.new("ShaderNodeNewGeometry")
       d_colorramp = nodes.new("ShaderNodeValToRGB")
       d_emission = nodes.new("ShaderNodeEmission")
       d_output   = nodes.new("ShaderNodeOutputMaterial")
       d_image   = nodes.new("ShaderNodeTexImage")

       d_geometry.location = (-100,-100)
       d_colorramp.location = (200,-100)      
       d_emission.location = (500,-100)
       d_output.location = (700,-100)
       d_image.location = (300,300)

       d_image.image = tex
       d_colorramp.color_ramp.elements[0].position = 0.4
       d_colorramp.color_ramp.elements[1].position = 0.6

       links.new( d_output.inputs['Surface'], d_emission.outputs['Emission'])
       links.new( d_emission.inputs['Color'], d_colorramp.outputs['Color'])
       links.new( d_colorramp.inputs['Fac'], d_geometry.outputs['Pointiness'])

#BAKING
#########################

#Curvature map

#remove every material slot of the high poly
bpy.ops.object.select_all(action = 'DESELECT')

bpy.ops.object.select_pattern(pattern="tmpHP")
bpy.context.scene.objects.active = bpy.data.objects["tmpHP"]

for ob in bpy.context.selected_editable_objects:
    ob.active_material_index = 0
    for i in range(len(ob.material_slots)):
        bpy.ops.object.material_slot_remove({'object': ob})

bpy.ops.object.select_pattern(pattern="tmpLP")
bpy.context.scene.objects.active = bpy.data.objects["tmpLP"]

print("\n&gt; Baking: curvature map\n")

bpy.data.objects['tmpHP'].active_material = bpy.data.materials['CURVATURE']
bpy.data.objects['tmpLP'].active_material = bpy.data.materials['CURVATURE']
bpy.ops.object.bake(type="EMIT", use_selected_to_active = True, use_cage = True, cage_extrusion = cage_size, margin = edge_padding, use_clear = True)