# Path: resources/lib/model/settings/category.py
# class Category(object):
#     def __init__(self, cat_id, cat_label, priority):
#         self.cat_id = cat_id
#         self.cat_label = cat_label
#         self.priority = priority
#         self.settings = {}
# 
# Path: resources/lib/model/settings/setting.py
# class Setting(object):
#     def __init__(self, setting_id, setting_label, priority, *args, **kwargs):
#         self.setting_id = setting_id
#         self.setting_label = setting_label
#         self.priority = priority
# 
#         if 'type' in kwargs.keys():
#             self.type = kwargs['type']
#         else:
#             self.type = None  # TODO: This should never happen
# 
#         if 'default' in kwargs.keys():
#             self.default = kwargs['default']
#         else:
#             self.default = None
# 
#         if 'visible' in kwargs.keys():
#             self.visible = kwargs['visible']
#         else:
#             self.visible = None
# 
#         if 'enable' in kwargs.keys():
#             self.enable = kwargs['enable']
#         else:
#             self.enable = None
# 
#         if 'values' in kwargs.keys():
#             self.values = kwargs['values']  # TODO: Parse into list
#         else:
#             self.values = None
# 
#         if 'range' in kwargs.keys():
#             self.range = kwargs['range']  # TODO: Parse into list
#         else:
#             self.range = None
# 
#         if 'option' in kwargs.keys():
#             self.option = kwargs['option']
#         else:
#             self.option = None
# 
#         if 'subsetting' in kwargs.keys():
#             self.subsetting = kwargs['subsetting']
#         else:
#             self.subsetting = None
# 
#         if 'current_value' in kwargs.keys():
#             self.current_value = kwargs['current_value']
#         else:
#             self.current_value = self.default
# 
#         if 'action' in kwargs.keys():
#             self.route = kwargs['action']
#         else:
#             self.route = None
# 
#         if 'file_mask' in kwargs.keys():
#             self.file_mask = kwargs['file_mask']
#         else:
#             self.file_mask = ""


import hashlib
import os
import xml.etree.ElementTree as ET
from resources.lib.model.settings.category import Category
from resources.lib.model.settings.setting import Setting

    def get_settings(self):
        if self.settings_hash == self._get_settings_hash() and len(self.settings_dict) > 0:
            self.update_values()
            return self.settings_dict
        else:
            self._reload_settings()

            cat_prio = 1

            for category in self.settings_tree.findall('category'):
                cat_label_id = category.get('label')
                cat_label = self.core.string(int(cat_label_id))
                cat = Category(cat_label_id, cat_label, cat_prio)
                cat_prio += 1

                setting_prio = 1
                for setting in category.findall('setting'):
                    if setting.get('label') is not None:
                        setting_label_id = setting.get('label')
                        setting_id = setting.get('id')
                        setting_label = self.core.string(int(setting_label_id))

                        setting_args = {}
                        for item in setting.items():
                            setting_args[item[0]] = item[1]

                        current_value = self.core.get_setting(setting_id)
                        setting_args['current_value'] = current_value


# Path: resources/lib/model/settings/category.py
# class Category(object):
#     def __init__(self, cat_id, cat_label, priority):
#         self.cat_id = cat_id
#         self.cat_label = cat_label
#         self.priority = priority
#         self.settings = {}
# 
# Path: resources/lib/model/settings/setting.py
# class Setting(object):
#     def __init__(self, setting_id, setting_label, priority, *args, **kwargs):
#         self.setting_id = setting_id
#         self.setting_label = setting_label
#         self.priority = priority
# 
#         if 'type' in kwargs.keys():
#             self.type = kwargs['type']
#         else:
#             self.type = None  # TODO: This should never happen
# 
#         if 'default' in kwargs.keys():
#             self.default = kwargs['default']
#         else:
#             self.default = None
# 
#         if 'visible' in kwargs.keys():
#             self.visible = kwargs['visible']
#         else:
#             self.visible = None
# 
#         if 'enable' in kwargs.keys():
#             self.enable = kwargs['enable']
#         else:
#             self.enable = None
# 
#         if 'values' in kwargs.keys():
#             self.values = kwargs['values']  # TODO: Parse into list
#         else:
#             self.values = None
# 
#         if 'range' in kwargs.keys():
#             self.range = kwargs['range']  # TODO: Parse into list
#         else:
#             self.range = None
# 
#         if 'option' in kwargs.keys():
#             self.option = kwargs['option']
#         else:
#             self.option = None
# 
#         if 'subsetting' in kwargs.keys():
#             self.subsetting = kwargs['subsetting']
#         else:
#             self.subsetting = None
# 
#         if 'current_value' in kwargs.keys():
#             self.current_value = kwargs['current_value']
#         else:
#             self.current_value = self.default
# 
#         if 'action' in kwargs.keys():
#             self.route = kwargs['action']
#         else:
#             self.route = None
# 
#         if 'file_mask' in kwargs.keys():
#             self.file_mask = kwargs['file_mask']
#         else:
#             self.file_mask = ""


# Path: resources/lib/util/settingsparser.py
import hashlib
import os
import xml.etree.ElementTree as ET
from resources.lib.model.settings.category import Category
from resources.lib.model.settings.setting import Setting


    def get_settings(self):
        if self.settings_hash == self._get_settings_hash() and len(self.settings_dict) > 0:
            self.update_values()
            return self.settings_dict
        else:
            self._reload_settings()

            cat_prio = 1

            for category in self.settings_tree.findall('category'):
                cat_label_id = category.get('label')
                cat_label = self.core.string(int(cat_label_id))
                cat = Category(cat_label_id, cat_label, cat_prio)
                cat_prio += 1

                setting_prio = 1
                for setting in category.findall('setting'):
                    if setting.get('label') is not None:
                        setting_label_id = setting.get('label')
                        setting_id = setting.get('id')
                        setting_label = self.core.string(int(setting_label_id))

                        setting_args = {}
                        for item in setting.items():
                            setting_args[item[0]] = item[1]

                        current_value = self.core.get_setting(setting_id)
                        setting_args['current_value'] = current_value


                        _setting = Setting(setting_id, setting_label, setting_prio, **setting_args)