I am trying to create a Script that does a Smart UV unwrap of seperate connected parts of a mesh
I finally got something that works, it's slow as molasses, but works.

    def execute(self, context):     # execute() is called by blender when running the operator

        while (hasMoreVerts()):
            bpy.ops.uv.smart_project()
            bpy.ops.mesh.hide(unselected = False)
            bpy.ops.object.mode_set( mode = 'OBJECT' )

        return {'FINISHED'}         # this lets blender know that the operator finished successfully

def register():
    bpy.utils.register_class(LightMapUVUnwrapper)

def unregister():
    bpy.utils.unregister_class(LightMapUVUnwrapper)

if __name__ == "__main__":
    register()

def hasMoreVerts():
    bpy.ops.object.mode_set(mode="EDIT")
    bpy.ops.mesh.select_all(action="DESELECT")
    bpy.context.tool_settings.mesh_select_mode = (True , False , False)
    mesh=bmesh.from_edit_mesh(bpy.context.object.data)

    if hasattr(mesh.verts, "ensure_lookup_table"): 
        mesh.verts.ensure_lookup_table()

    for vert in mesh.verts:
        if (not vert.hide):
            vert.select = True
            bpy.ops.mesh.select_linked()
            return True

    return false