def loadBrushPreset(self, name):
        """
        Loads a brush preset name.preset
        :param name, name of the preset to load.
        """
        name += '.preset'
        f = None
        try:
            f = open(os.path.join(directories.brushesDir, name), "r")
        except:
            alert('Exception while trying to load preset. See console for details.')
        loadedBrushOptions = ast.literal_eval(f.read())
        if f:
            f.close()

        brushMode = self.brushModes.get(loadedBrushOptions.get("Mode", None), None)
        if brushMode is not None:
            self.selectedBrushMode = loadedBrushOptions["Mode"]
            self.brushMode = self.brushModes[self.selectedBrushMode]
            for key in loadedBrushOptions:
                if key.endswith('blockID'):
                    key = key[:-7]
                    self.options[key] = self.editor.level.materials.blockWithID(loadedBrushOptions[key + 'blockID'], loadedBrushOptions[key + 'blockData'])
                    if key + 'recentBlocks' in loadedBrushOptions:
                        list = []
                        blockList = loadedBrushOptions[key + 'recentBlocks']
                        for b in blockList:
                            list.append(self.editor.level.materials.blockWithID(b[0], b[1]))
                        self.recentBlocks[key] = list
                elif key.endswith('blockData'):
                    continue
                elif key.endswith('recentBlocks'):
                    continue
                else:
                    self.options[key] = loadedBrushOptions[key]
        self.showPanel()
        self.setupPreview()

        Loads a brush preset name.preset
        :param name, name of the preset to load.
        
editortools/brush.py