diff --git a/virtinst/storage.py b/virtinst/storage.py index 210e8573..b63ca31e 100644 --- a/virtinst/storage.py +++ b/virtinst/storage.py @@ -146,8 +146,7 @@ class StoragePool(_StorageObject): for source in sources.sources: source_xml = source.get_xml() - pool_xml = "\n%s\n" % ( - util.xml_indent(source_xml, 2)) + pool_xml = "\n%s\n" % source_xml parseobj = StoragePool(conn, parsexml=pool_xml) parseobj.type = pool_type diff --git a/virtinst/util.py b/virtinst/util.py index 7219d49f..a7eb5c9a 100644 --- a/virtinst/util.py +++ b/virtinst/util.py @@ -23,18 +23,6 @@ def listify(l): return l -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 vm_uuid_collision(conn, uuid): """ Check if passed UUID string is in use by another guest of the connection diff --git a/virtinst/xmlbuilder.py b/virtinst/xmlbuilder.py index 8e55a63c..024ef1f0 100644 --- a/virtinst/xmlbuilder.py +++ b/virtinst/xmlbuilder.py @@ -10,7 +10,8 @@ import collections import logging import os import re -import string # pylint: disable=deprecated-module +import string +import textwrap from .xmlapi import XMLAPI from . import util @@ -691,7 +692,7 @@ class XMLBuilder(object): use_xpath = obj._xmlstate.abs_xpath().rsplit("/", 1)[0] indent = 2 * obj._xmlstate.abs_xpath().count("/") self._xmlstate.xmlapi.node_add_xml( - util.xml_indent(xml, indent), use_xpath) + textwrap.indent(xml, indent * " "), use_xpath) obj._parse_with_children(None, self._xmlstate) def remove_child(self, obj): @@ -720,7 +721,7 @@ class XMLBuilder(object): if not self._xmlstate.is_build: xpath = origobj.get_xml_id() indent = 2 * xpath.count("/") - xml = util.xml_indent(newobj.get_xml(), indent).strip() + xml = textwrap.indent(newobj.get_xml(), indent * " ").strip() self._xmlstate.xmlapi.node_replace_xml(xpath, xml) else: origidx = origobj.get_xml_idx()