xmlapi: Move namespace mappings to the relevant classes

So we don't need to update xmlapi.py to account for additions
This commit is contained in:
Cole Robinson 2018-09-13 09:34:04 -04:00
parent 6063538750
commit 841d5126d2
3 changed files with 13 additions and 3 deletions

View File

@ -7,6 +7,10 @@
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
XMLBuilder.register_namespace(
"qemu", "http://libvirt.org/schemas/domain/qemu/1.0")
class _XMLNSQemuArg(XMLBuilder):
XML_NAME = "qemu:arg"

View File

@ -76,9 +76,10 @@ class _XPath(object):
class _XMLBase(object):
NAMESPACES = {
"qemu": "http://libvirt.org/schemas/domain/qemu/1.0",
}
NAMESPACES = {}
@classmethod
def register_namespace(cls, nsname, uri):
cls.NAMESPACES[nsname] = uri
def copy_api(self):
raise NotImplementedError()

View File

@ -419,6 +419,11 @@ class XMLBuilder(object):
# https://bugzilla.redhat.com/show_bug.cgi?id=1184131
_XML_SANITIZE = False
@staticmethod
def register_namespace(nsname, uri):
XMLAPI.register_namespace(nsname, uri)
def __init__(self, conn, parsexml=None,
parentxmlstate=None, relative_object_xpath=None):
"""