""" NETCONF for APK Distributions server: Higher-level utility functions. Copyright © 2020 Adélie Software in the Public Benefit, Inc. Released under the terms of the NCSA license. See the LICENSE file included with this source distribution for more information. SPDX-License-Identifier: NCSA """ from lxml.etree import QName from netconf import error from ncserver.base.modman import MODMAN def maybe_raise_on_invalid_node(xmlns, rpc, node): """Determine if this node should cause the module in namespace to raise. :param str xmlns: The xmlns of the current module. :param rpc: The RPC causing this lookup to happen. :param node: The node in question. """ nodens = QName(node).namespace if nodens == xmlns: raise error.UnknownElementAppError(rpc, node) if nodens not in (mod.M_PREFIX for mod in MODMAN._augments_for_ns(xmlns)): raise error.UnknownNamespaceAppError(rpc, node, None)