def create_config(self): path = os.path.dirname(CONFIG_PATH) if not os.path.exists(path): os.mkdir(path) config = ConfigParser() if os.path.exists(CONFIG_PATH): config.read(CONFIG_PATH) def save_config(): with open(CONFIG_PATH, 'w') as configfile: config.write(configfile) os.chmod(CONFIG_PATH, 0600) config.save = save_config return config