From 0e4d09aea4caf13e0f994cbb042a0dbf98719820 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Sat, 5 Aug 2023 19:16:23 -0500 Subject: config: T5443: add config merge_defaults method Drop low-level merge_defaults function in favor of Config method for a middle-grained level of control when merging defaults. --- python/vyos/xml_ref/__init__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'python/vyos/xml_ref/__init__.py') diff --git a/python/vyos/xml_ref/__init__.py b/python/vyos/xml_ref/__init__.py index 9f7a31e2c..02bbaffd8 100644 --- a/python/vyos/xml_ref/__init__.py +++ b/python/vyos/xml_ref/__init__.py @@ -13,9 +13,12 @@ # You should have received a copy of the GNU Lesser General Public License # along with this library. If not, see . -from typing import Optional, Union +from typing import Optional, Union, TYPE_CHECKING from vyos.xml_ref import definition +if TYPE_CHECKING: + from vyos.config import ConfigDict + def load_reference(cache=[]): if cache: return cache[0] @@ -49,9 +52,6 @@ def is_leaf(path: list) -> bool: def cli_defined(path: list, node: str, non_local=False) -> bool: return load_reference().cli_defined(path, node, non_local=non_local) -def from_source(d: dict, path: list) -> bool: - return load_reference().from_source(d, path) - def component_version() -> dict: return load_reference().component_version() @@ -72,8 +72,8 @@ def relative_defaults(rpath: list, conf: dict, get_first_key=False, get_first_key=get_first_key, recursive=recursive) -def merge_defaults(path: list, conf: dict, get_first_key=False, - recursive=False) -> dict: - return load_reference().merge_defaults(path, conf, - get_first_key=get_first_key, - recursive=recursive) +def from_source(d: dict, path: list) -> bool: + return definition.from_source(d, path) + +def ext_dict_merge(source: dict, destination: Union[dict, 'ConfigDict']): + return definition.ext_dict_merge(source, destination) -- cgit v1.2.3