Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: cleanup config dir/file handling #666

Merged
merged 9 commits into from
Oct 11, 2024
Merged

Conversation

Morg42
Copy link
Member

@Morg42 Morg42 commented Jul 23, 2024

creating/guessing config dirs and config files has been quite wild (and not always consistent) throughout shng, and not all methods were prepared to honor extern_conf_dir or config_etc.

  • lib.smarthome has new methods:
    • get_config_dir(config)
    • get_config_file(basename)
      both use existing methods or variables and create a single centralized point to access shng's config dirs and files (no more accessing sh._etc_dir or os.path.join-ing chains, mostly)
      exceptions are sh.get_basedir and sh.get_confdir (for extern_conf_dir) as I see these to be special cases. They could be adjusted quite easily, though
  • lib.constants has a bunch of DIR_FOO and BASE_BAR constants designating config dirs and config file basenames. These can (should) be used in calls to the mentioned methods.
  • these are also present in the test mockup core
  • all lib/.py and module/admin/.py use these methods consistently

Running different setups and tests all went smoothly, threw/logged no errors and functioned as intended, so no obvious errors

All "legacy" methods and vars are still available, so not using the new methods will still function (non-breaking change); we might designate the old methods deprecated at some later time.

I intend to merge this soon; though non-breaking, I offer the PR up for testing on other setups beforehand.

@Morg42 Morg42 self-assigned this Jul 23, 2024
@Morg42 Morg42 merged commit 386fe1e into smarthomeNG:develop Oct 11, 2024
5 checks passed
@Morg42 Morg42 deleted the conf-1 branch October 11, 2024 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant