def saveBrushPreset(self, name):
        """
        Saves current brush presets in a file name.preset
        :param name, name of the file to store the preset in.
        """
        optionsToSave = {}
        for key in self.options:
            if self.options[key].__class__.__name__ == 'Block':
                optionsToSave[key + 'blockID'] = self.options[key].ID
                optionsToSave[key + 'blockData'] = self.options[key].blockData
                saveList = []
                if key in self.recentBlocks:
                    blockList = self.recentBlocks[key]
                    for b in blockList:
                        saveList.append((b.ID, b.blockData))
                    optionsToSave[key + 'recentBlocks'] = saveList
            elif self.options[key].__class__.__name__ == 'instancemethod':
                continue
            else:
                optionsToSave[key] = self.options[key]
        optionsToSave["Mode"] = getattr(self, 'selectedBrushMode', 'Fill')
        name += ".preset"
        f = open(os.path.join(directories.brushesDir, name), "w")
        f.write(repr(optionsToSave))

        Saves current brush presets in a file name.preset
        :param name, name of the file to store the preset in.
        
editortools/brush.py