"""
Overload of the BWizardPage reloadData method.
"""
- self.project.loadProjectPresets()
+ self._fillPresetTree()
####
####
+ def _fillPresetTree(self):
+ self.project.loadProjectPresets()
+ preset_tree = self.project.info("PRESET_TREE")
+ for obj in preset_tree['children']:
+ self._createPresetNode(self.pageContent.boardTree, obj)
+
+ def _createPresetNode(self, parent, obj):
+ item_name = obj['info'].get('name', obj['info']['filename'])
+ item = QTreeWidgetItem(parent, [item_name])
+ children_dict = obj['children']
+ for child in children_dict:
+ self._createPresetNode(item, child)
"""
# NOTE: this method does nothing (for now).
preset_path = os.path.join(self.infos["SOURCES_PATH"], const.PREDEFINED_BOARDS_DIR)
+ preset_tree = {}
+ if os.path.exists(preset_path):
+ preset_tree = self._loadProjectPresetTree(preset_path)
+ self.infos["PRESET_TREE"] = preset_tree
+
+ def _loadProjectPresetTree(self, path):
+ _tree = {}
+ _tree['info'] = self._loadPresetInfo(os.path.join(path, const.PREDEFINED_BOARD_SPEC_FILE))
+ _tree['info']['filename'] = os.path.basename(path)
+ _tree['children'] = []
+ entries = set(os.listdir(path))
+ for entry in entries:
+ _path = os.path.join(path, entry)
+ if os.path.isdir(_path):
+ sub_entries = set(os.listdir(_path))
+ if const.PREDEFINED_BOARD_SPEC_FILE in sub_entries:
+ _tree['children'].append(self._loadProjectPresetTree(_path))
+ return _tree
+
+ def _loadPresetInfo(self, preset_spec_file):
+ D = {}
+ execfile(preset_spec_file, {}, D)
+ return D
def loadModuleData(self, edit=False):
module_info_dict = {}
del _tmp
PREDEFINED_BOARDS_DIR = 'predefined_boards'
+PREDEFINED_BOARD_SPEC_FILE = '.spec'
+# PREDEFINED_BOARD_SPEC_INFO = {
+# 'name': <name of the board/directory>,
+# 'description': <description of the board/directory>,
+# }
CPU_DEF = {
"CPU_NAME": "",