'''
Created on Oct 27, 2021

@author: terry
'''

import os, random
import yaml
import lunagen.addon

class SoftwareList(lunagen.addon.LunaGenAddOn):
    """
    Software List with Banners.
    """
    name = 'softwarelist'
    desc = """\
Display a set of selected software mini-banners.
"""
    file = __file__
    
    @staticmethod
    def load(site):
        if site.verbose: print("Loading software data.")
        try:
            with open(os.path.join(site.datadir, 'software.yaml')) as sw_file:
                softwarelist = yaml.safe_load(sw_file)
            # stylesheets = []
            # if 'stylesheets' in site.sitedata:
            #     stylesheets.extend(site.sitedata['stylesheets'])
            site.sitedata.update(softwarelist)
            site.sitedata['stylesheets'] = site._collect_stylesheets(softwarelist)
        except FileNotFoundError:
            print("No software.yaml file, so software list is empty.")
            site.sitedata['softwarelist'] = []
    
        
            