From 8efaa4edc4ebff8a44772e70c203c5b422ea312a Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Tue, 24 Mar 2026 11:32:12 -0700 Subject: [PATCH] Tighter criteria for relocated schema Also, better comments. --- src/weewx/manager.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/weewx/manager.py b/src/weewx/manager.py index 901b3336..3f4a35e5 100644 --- a/src/weewx/manager.py +++ b/src/weewx/manager.py @@ -899,10 +899,18 @@ def get_manager_dict_from_config(config_dict, data_binding, try: manager_dict['schema'] = weeutil.weeutil.get_object(schema_name) except (ModuleNotFoundError, ImportError) as e: + # The following is for backwards compatibility. With V5.1 and earlier, the schemas + # were located in module 'schemas'. Now they are in module 'weewx.schemas'.' Try + # to find the new location. However, if the module name does not start with + # 'schemas.', then we don't know anything about it. + if not schema_name.startswith('schemas.'): + raise + # Try the new location. log.debug("Could not load schema '%s'", schema_name) log.debug("**** Reason: %s", e) log.debug("**** Trying '%s'", 'weewx.' + schema_name) manager_dict['schema'] = weeutil.weeutil.get_object('weewx.' + schema_name) + log.debug("**** Succeeded.") return manager_dict