mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-24 02:04:13 +03:00
util: Move xml_indent to XMLBuilder
This commit is contained in:
parent
5dea1c2d80
commit
eb2a56f700
@ -177,7 +177,8 @@ class StoragePool(_StorageObject):
|
||||
for source in sources.sources:
|
||||
source_xml = source.get_xml_config()
|
||||
|
||||
pool_xml = "<pool>\n%s\n</pool>" % (util.xml_indent(source_xml, 2))
|
||||
pool_xml = "<pool>\n%s\n</pool>" % (
|
||||
XMLBuilder.xml_indent(source_xml, 2))
|
||||
parseobj = StoragePool(conn, parsexml=pool_xml)
|
||||
parseobj.type = pool_type
|
||||
|
||||
|
@ -36,15 +36,6 @@ def listify(l):
|
||||
return l
|
||||
|
||||
|
||||
def xml_indent(xmlstr, level):
|
||||
xml = ""
|
||||
if not xmlstr:
|
||||
return xml
|
||||
if not level:
|
||||
return xmlstr
|
||||
return "\n".join((" " * level + l) for l in xmlstr.splitlines())
|
||||
|
||||
|
||||
def vm_uuid_collision(conn, uuid):
|
||||
"""
|
||||
Check if passed UUID string is in use by another guest of the connection
|
||||
|
@ -775,6 +775,20 @@ class XMLBuilder(object):
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1184131
|
||||
_XML_SANITIZE = False
|
||||
|
||||
|
||||
@staticmethod
|
||||
def xml_indent(xmlstr, level):
|
||||
"""
|
||||
Indent the passed str the specified number of spaces
|
||||
"""
|
||||
xml = ""
|
||||
if not xmlstr:
|
||||
return xml
|
||||
if not level:
|
||||
return xmlstr
|
||||
return "\n".join((" " * level + l) for l in xmlstr.splitlines())
|
||||
|
||||
|
||||
def __init__(self, conn, parsexml=None, parsexmlnode=None,
|
||||
parent_xpath=None, relative_object_xpath=None):
|
||||
"""
|
||||
@ -1020,7 +1034,7 @@ class XMLBuilder(object):
|
||||
if not obj._xmlstate.is_build:
|
||||
use_xpath = obj.get_root_xpath().rsplit("/", 1)[0]
|
||||
indent = 2 * obj.get_root_xpath().count("/")
|
||||
newnode = libxml2.parseDoc(util.xml_indent(xml, indent)).children
|
||||
newnode = libxml2.parseDoc(self.xml_indent(xml, indent)).children
|
||||
parentnode = _build_xpath_node(self._xmlstate.xml_ctx, use_xpath)
|
||||
# Tack newnode on the end
|
||||
_add_pretty_child(parentnode, newnode)
|
||||
|
Loading…
x
Reference in New Issue
Block a user