Skip to content

Rewrote config file handling

Benjamin Winger requested to merge bmwinger/portmod:config_abstraction into master

This is a big change, and there are a few things left to be done.

Changes:

  • Config files are specified through the repository.
  • We now support a subset of python in the config, allowing config files to be more expressive. RestrictedPython is used for this, as it ensures that config files do not have side effects. The only builtins currently available are the Config object (for declaring config files) and the join function (equivalent to os.path.join).

Todo:

  • Documentation. Lots of new/changed features in this merge request. Edit. Actually fairly minimal discounting the profile documentation, which hasn't been written yet. I'm planning on leaving that for later given that it's less relevant to users.
  • Make configs be able to specify iniparser support, rather than enable/disable section headers. When this is enabled, iniparser should be used to write to the file. This won't sort the lines, but we can provide an {i} variable that can be used to indicate that an entry should include it's sorted number. (basically, this will support things like Morrowind.ini, as well as openmw's settings.cfg)
  • Support hardcoded config entries (entries themselves specified in the profile). This can be used to do things such as redirect tes3cmd to look for custom scripts in a certain location by adding the appropriate line to its config.
  • Fix now-broken omwmerge --validate. This should warn about extraneous config entries, as well as compare the installed mods database (where we get config lines from) to the installed mods.
  • User config override. I.e. directory in the config dir where the user can add config entries that will override those from the mods. For now this should be mainly focused towards settings files such as settings.cfg (i.e. ini type files) as well as overriding keys in openmw.cfg, particularly fallback entries. Specifying sort order shouldn't really be necessary, as that should be done by other mechanisms, though we could revisit the idea later. Primary issue: what should the filename of the override file be? Equivalent to the config file basename itself, or perhaps the key used in the portmod config files. This might need to be deferred if only because the solution is not clear and this isn't as important.

Closes #55 (closed) and #46 (closed).

There are changes required for the mod repo, as we've changed how defaults.cfg works in profiles.

Edited by Benjamin Winger

Merge request reports