'Set new preset for a given category'

def set_slic3r_config(self, configfile, cat, file):

    self.slic3r_configs[cat] = file
    if self.settings.slic3rupdate:
        config = self.read_slic3r_config(configfile)
        version = config.get('dummy', 'version')
        preset = os.path.basename(file)
        if (version.split('.') >= ['1', '3', '0']):
            preset = os.path.splitext(preset)[0]
        config.set('presets', cat, preset)
        f = StringIO.StringIO()
        config.write(f)
        data = f.getvalue()
        f.close()
        data = data.replace('[dummy]\n', '')
        with open(configfile, 'w') as f:
            f.write(data)
