Reducing numer of updates of a dynamic EnumProperty

Hey guys,

i want to import League of Legends skins. For that i open an inibin file, which contains information about several skin names. So the idea is that there is a file browsing dialog and as soon as you highlight an .inibin file, the skin names will be retrieved from the .inibin and put into a drop down list, so that one can choose which skin to import.

def get_available_skins(self, context):
    path = self.filepath
    if os.path.isfile(self.filepath):
        skin_names = []
        print("reading again")
        for skin in import_lolskin.get_available_skins(self.filepath):
            skin_names.append((skin.name, skin.name, skin.name))
        return skin_names
    else:
        return []


class ImportLolSkin(bpy.types.Operator, bpy_extras.io_utils.ImportHelper):
    bl_idname = "import_scene.lolskin"
    bl_label = "Import LoL skin"
    bl_description = "Opens .inibin file and imports one of the contained " \
                     "skins."
    bl_options = {'UNDO'}

    filename_ext = ".inibin"
    filter_glob = StringProperty(default="*.inibin", options={'HIDDEN'})
    filepath = StringProperty(name="File path")

    skin_name = bpy.props.EnumProperty(name="Choose skin:",
                                       description="Choose one of these "
                                                    "available skins.",
                                       items=get_available_skins,
                                       update=None)

    def execute(self, context):
        import_lolskin.import_lolskin(self.skin_name, self.filepath, context)
        print("finished")
        return {'FINISHED'}

As you can see i use a dynamic EnumProperty for the drop down list and this works really well. However, the problem is that the EnumProperty calls the “get_available_skins” function 3 times when an .inibin file is selected, and also repeatedly calls it when selecting different values from the dropdown list. As “import_lolskin.get_available_skins” reads the .inibin file, there are a lot of file reads while really only one would be necessary :/.

I tried to only read when the file changed, but then i have the problem that i can’t tell the EnumProperty “stay how you are” in get_available_skins.

Is there any better way to achieve what i want?