[cli/utils] Automatically create missing config sections

This commit is contained in:
derrod 2021-09-02 19:15:29 +02:00
parent 0416b472d3
commit 4d5539c889
3 changed files with 6 additions and 6 deletions

View file

@ -598,8 +598,6 @@ class LegendaryCLI:
config_tags = self.core.lgd.config.get(game.app_name, 'install_tags', fallback=None)
if not self.core.is_installed(game.app_name) or config_tags is None or args.reset_sdl:
args.install_tag = sdl_prompt(sdl_name, game.app_title)
if game.app_name not in self.core.lgd.config:
self.core.lgd.config[game.app_name] = dict()
self.core.lgd.config.set(game.app_name, 'install_tags', ','.join(args.install_tag))
else:
args.install_tag = config_tags.split(',')

View file

@ -1152,8 +1152,6 @@ class LegendaryCore:
# transfer install tag choices to config
if lgd_igame.install_tags:
if app_name not in self.lgd.config:
self.lgd.config[app_name] = dict()
self.lgd.config.set(app_name, 'install_tags', ','.join(lgd_igame.install_tags))
# mark game as installed

View file

@ -22,12 +22,16 @@ class LGDConf(configparser.ConfigParser):
super().write(*args, **kwargs)
self.modtime = int(time.time())
def set(self, *args, **kwargs):
def set(self, section, option, value=None):
if self.read_only:
return
# ensure config section exists
if not self.has_section(section):
self.add_section(section)
self.modified = True
super().set(*args, **kwargs)
super().set(section, option, value)
def remove_option(self, section, option):
if self.read_only: