<commit_before>import os
import bpy
import bpy.utils.previews
from .. import util

asset_previews = bpy.utils.previews.new()

def load_previews(lib, start=0):
    global asset_previews
    enum_items = []

    lib_dir = presets_library = util.get_addon_prefs().presets_library.path

    for i,asset in enumerate(lib.presets):
        path = asset.path
        
        if path not in asset_previews:
            thumb_path = os.path.join(asset.path, 'asset_100.png')
            
            thumb = asset_previews.load(path, thumb_path, 'IMAGE', force_reload=True)
        else:
            thumb = asset_previews[path]
        enum_items.append((asset.path, asset.label, '', thumb.icon_id, start + i))
        
    start += len(enum_items)
    for sub_group in lib.sub_groups:
        enum_items.extend(load_previews(sub_group, start))

    return enum_items if enum_items else [('', '', '')]<commit_msg>Fix order in icon preview.<commit_after>import os
import bpy
import bpy.utils.previews
from .. import util

asset_previews = bpy.utils.previews.new()

def get_presets_for_lib(lib):
    items = list(lib.presets)
    for sub_group in lib.sub_groups:
        items.extend(get_presets_for_lib(sub_group))
    return items

def load_previews(lib):
    global asset_previews
    enum_items = []

    lib_dir = presets_library = util.get_addon_prefs().presets_library.path

    items = get_presets_for_lib(lib)
    items = sorted(items, key=lambda item: item.label)

    for i, asset in enumerate(items):
        path = asset.path
        
        if path not in asset_previews:
            thumb_path = os.path.join(asset.path, 'asset_100.png')
            
            thumb = asset_previews.load(path, thumb_path, 'IMAGE', force_reload=True)
        else:
            thumb = asset_previews[path]
        enum_items.append((asset.path, asset.label, '', thumb.icon_id, i))

    return enum_items if enum_items else [('', '', '')]
{'fraction_non_alphanumeric': 0.10725388601036269, 'fraction_numerical': 0.003626943005181347, 'mean_word_length': 2.8775100401606424, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1628270', 'n_tokens_mistral': 633, 'n_tokens_neox': 617, 'n_words': 133}