virtinst: Rename util to xmlutil
The only functions left in there are largely for xml handling, so make it explicit
This commit is contained in:
parent
6677f677da
commit
388850f04e
|
@ -66,12 +66,12 @@ class XMLParseTest(unittest.TestCase):
|
|||
Check expected initial value obj.param == initval, then
|
||||
set newval, and make sure it is returned properly
|
||||
"""
|
||||
curval = virtinst.util.get_prop_path(obj, param)
|
||||
curval = virtinst.xmlutil.get_prop_path(obj, param)
|
||||
self.assertEqual(initval, curval)
|
||||
|
||||
for newval in args:
|
||||
virtinst.util.set_prop_path(obj, param, newval)
|
||||
curval = virtinst.util.get_prop_path(obj, param)
|
||||
virtinst.xmlutil.set_prop_path(obj, param, newval)
|
||||
curval = virtinst.xmlutil.get_prop_path(obj, param)
|
||||
self.assertEqual(newval, curval)
|
||||
|
||||
def _make_checker(self, obj):
|
||||
|
|
14
virt-install
14
virt-install
|
@ -105,11 +105,11 @@ def convert_old_init(options):
|
|||
|
||||
|
||||
def _do_convert_old_disks(options):
|
||||
paths = virtinst.util.listify(options.file_paths)
|
||||
sizes = virtinst.util.listify(options.disksize)
|
||||
paths = virtinst.xmlutil.listify(options.file_paths)
|
||||
sizes = virtinst.xmlutil.listify(options.disksize)
|
||||
|
||||
def padlist(l, padsize):
|
||||
l = virtinst.util.listify(l)
|
||||
l = virtinst.xmlutil.listify(l)
|
||||
l.extend((padsize - len(l)) * [None])
|
||||
return l
|
||||
|
||||
|
@ -198,9 +198,9 @@ def convert_old_networks(options):
|
|||
fail(_("Cannot use --nonetworks with --network"))
|
||||
options.network = ["none"]
|
||||
|
||||
macs = virtinst.util.listify(options.mac)
|
||||
networks = virtinst.util.listify(options.network)
|
||||
bridges = virtinst.util.listify(options.bridge)
|
||||
macs = virtinst.xmlutil.listify(options.mac)
|
||||
networks = virtinst.xmlutil.listify(options.network)
|
||||
bridges = virtinst.xmlutil.listify(options.bridge)
|
||||
|
||||
if bridges and networks:
|
||||
fail(_("Cannot mix both --bridge and --network arguments"))
|
||||
|
@ -210,7 +210,7 @@ def convert_old_networks(options):
|
|||
networks = ["bridge:" + b for b in bridges]
|
||||
|
||||
def padlist(l, padsize):
|
||||
l = virtinst.util.listify(l)
|
||||
l = virtinst.xmlutil.listify(l)
|
||||
l.extend((padsize - len(l)) * [None])
|
||||
return l
|
||||
|
||||
|
|
10
virt-xml
10
virt-xml
|
@ -15,7 +15,7 @@ import libvirt
|
|||
|
||||
import virtinst
|
||||
from virtinst import cli
|
||||
from virtinst import util
|
||||
from virtinst import xmlutil
|
||||
from virtinst.cli import fail, print_stdout, print_stderr
|
||||
|
||||
|
||||
|
@ -105,7 +105,7 @@ def get_domain_and_guest(conn, domstr):
|
|||
################
|
||||
|
||||
def _find_objects_to_edit(guest, action_name, editval, parserclass):
|
||||
objlist = util.listify(parserclass.lookup_prop(guest))
|
||||
objlist = xmlutil.listify(parserclass.lookup_prop(guest))
|
||||
idx = None
|
||||
|
||||
if editval is None:
|
||||
|
@ -199,7 +199,7 @@ def action_add_device(guest, options, parserclass):
|
|||
fail(_("Cannot use --add-device with --%s") % parserclass.cli_arg_name)
|
||||
set_os_variant(options, guest)
|
||||
devs = cli.parse_option_strings(options, guest, None)
|
||||
devs = util.listify(devs)
|
||||
devs = xmlutil.listify(devs)
|
||||
for dev in devs:
|
||||
dev.set_defaults(guest)
|
||||
return devs
|
||||
|
@ -215,7 +215,7 @@ def action_remove_device(guest, options, parserclass):
|
|||
devs = _find_objects_to_edit(guest, "remove-device",
|
||||
getattr(options, parserclass.cli_arg_name)[-1], parserclass)
|
||||
|
||||
devs = util.listify(devs)
|
||||
devs = xmlutil.listify(devs)
|
||||
for dev in devs:
|
||||
guest.remove_device(dev)
|
||||
return devs
|
||||
|
@ -236,7 +236,7 @@ def action_build_xml(conn, options, parserclass):
|
|||
inst = inst.__class__(conn)
|
||||
|
||||
devs = cli.parse_option_strings(options, guest, inst)
|
||||
devs = util.listify(devs)
|
||||
devs = xmlutil.listify(devs)
|
||||
for dev in devs:
|
||||
dev.set_defaults(guest)
|
||||
return devs
|
||||
|
|
|
@ -14,7 +14,7 @@ from gi.repository import Gdk
|
|||
from gi.repository import Pango
|
||||
|
||||
import virtinst
|
||||
from virtinst import util
|
||||
from virtinst import xmlutil
|
||||
|
||||
from .asyncjob import vmmAsyncJob
|
||||
from .baseclass import vmmGObjectUI
|
||||
|
@ -93,7 +93,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
|||
def reset_state(self):
|
||||
# Set VM name in title'
|
||||
title_str = ("<span size='large' color='white'>%s '%s'</span>" %
|
||||
(_("Delete"), util.xml_escape(self.vm.get_name())))
|
||||
(_("Delete"), xmlutil.xml_escape(self.vm.get_name())))
|
||||
self.widget("header-label").set_markup(title_str)
|
||||
|
||||
self.topwin.resize(1, 1)
|
||||
|
|
|
@ -11,7 +11,7 @@ from gi.repository import Gtk
|
|||
from gi.repository import Gdk
|
||||
from gi.repository import GdkPixbuf
|
||||
|
||||
from virtinst import util
|
||||
from virtinst import xmlutil
|
||||
|
||||
from . import vmmenu
|
||||
from . import uiutil
|
||||
|
@ -583,7 +583,7 @@ class vmmManager(vmmGObjectUI):
|
|||
return hint
|
||||
|
||||
def _build_conn_markup(self, conn, name):
|
||||
name = util.xml_escape(name)
|
||||
name = xmlutil.xml_escape(name)
|
||||
text = name
|
||||
if conn.is_disconnected():
|
||||
text += " - " + _("Not Connected")
|
||||
|
@ -601,7 +601,7 @@ class vmmManager(vmmGObjectUI):
|
|||
|
||||
def _build_vm_markup(self, name, status):
|
||||
domtext = ("<span size='smaller' weight='bold'>%s</span>" %
|
||||
util.xml_escape(name))
|
||||
xmlutil.xml_escape(name))
|
||||
statetext = "<span size='smaller'>%s</span>" % status
|
||||
return domtext + "\n" + statetext
|
||||
|
||||
|
@ -629,7 +629,7 @@ class vmmManager(vmmGObjectUI):
|
|||
row.insert(ROW_SORT_KEY, name)
|
||||
row.insert(ROW_MARKUP, markup)
|
||||
row.insert(ROW_STATUS_ICON, status_icon)
|
||||
row.insert(ROW_HINT, util.xml_escape(hint))
|
||||
row.insert(ROW_HINT, xmlutil.xml_escape(hint))
|
||||
row.insert(ROW_IS_CONN, bool(conn))
|
||||
row.insert(ROW_IS_CONN_CONNECTED,
|
||||
bool(conn) and not conn.is_disconnected())
|
||||
|
@ -701,7 +701,7 @@ class vmmManager(vmmGObjectUI):
|
|||
row[ROW_MARKUP] = self._build_vm_markup(name, status)
|
||||
|
||||
desc = vm.get_description()
|
||||
row[ROW_HINT] = util.xml_escape(desc)
|
||||
row[ROW_HINT] = xmlutil.xml_escape(desc)
|
||||
except Exception as e:
|
||||
if vm.conn.support.is_libvirt_error_no_domain(e):
|
||||
return
|
||||
|
@ -906,7 +906,7 @@ class vmmManager(vmmGObjectUI):
|
|||
widgn = "menu_view_stats_memory"
|
||||
do_enable = self.config.get_stats_enable_memory_poll()
|
||||
|
||||
for w in util.listify(widgn):
|
||||
for w in xmlutil.listify(widgn):
|
||||
widget = self.widget(w)
|
||||
tool_text = ""
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ from gi.repository import Gdk
|
|||
from gi.repository import Gtk
|
||||
from gi.repository import Pango
|
||||
|
||||
from virtinst import util
|
||||
from virtinst import xmlutil
|
||||
|
||||
from . import uiutil
|
||||
from .asyncjob import vmmAsyncJob
|
||||
|
@ -154,7 +154,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
|||
|
||||
def _reset_state(self):
|
||||
title_str = ("<span size='large' color='white'>%s '%s'</span>" %
|
||||
(_("Migrate"), util.xml_escape(self.vm.get_name())))
|
||||
(_("Migrate"), xmlutil.xml_escape(self.vm.get_name())))
|
||||
self.widget("header-label").set_markup(title_str)
|
||||
|
||||
self.widget("migrate-advanced-expander").set_expanded(False)
|
||||
|
|
|
@ -16,7 +16,7 @@ from gi.repository import Gtk
|
|||
from gi.repository import Pango
|
||||
|
||||
from virtinst import DomainSnapshot
|
||||
from virtinst import util
|
||||
from virtinst import xmlutil
|
||||
|
||||
from . import uiutil
|
||||
from .baseclass import vmmGObjectUI
|
||||
|
@ -460,8 +460,8 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||
sortname = "1%s" % name
|
||||
|
||||
label = "%s\n<span size='small'>%s: %s%s</span>" % (
|
||||
(util.xml_escape(name), _("VM State"),
|
||||
util.xml_escape(state), external))
|
||||
(xmlutil.xml_escape(name), _("VM State"),
|
||||
xmlutil.xml_escape(state), external))
|
||||
model.append([name, label, desc, snap.run_status_icon_name(),
|
||||
sortname, snap.is_current()])
|
||||
|
||||
|
@ -517,7 +517,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||
|
||||
title = ""
|
||||
if name:
|
||||
title = "<b>Snapshot '%s':</b>" % util.xml_escape(name)
|
||||
title = "<b>Snapshot '%s':</b>" % xmlutil.xml_escape(name)
|
||||
|
||||
uiutil.set_grid_row_visible(
|
||||
self.widget("snapshot-is-current"), is_current)
|
||||
|
|
|
@ -9,7 +9,7 @@ import logging
|
|||
from gi.repository import Gio
|
||||
from gi.repository import Gtk
|
||||
|
||||
from virtinst import util
|
||||
from virtinst import xmlutil
|
||||
|
||||
from . import vmmenu
|
||||
from .baseclass import vmmGObject
|
||||
|
@ -227,7 +227,7 @@ class vmmSystray(vmmGObject):
|
|||
menu_item = Gtk.MenuItem.new_with_label(conn.get_pretty_desc())
|
||||
if conn.is_active():
|
||||
label = menu_item.get_child()
|
||||
markup = "<b>%s</b>" % util.xml_escape(conn.get_pretty_desc())
|
||||
markup = "<b>%s</b>" % xmlutil.xml_escape(conn.get_pretty_desc())
|
||||
label.set_markup(markup)
|
||||
|
||||
menu = Gtk.Menu()
|
||||
|
|
|
@ -14,7 +14,7 @@ import re
|
|||
import shlex
|
||||
|
||||
import virtinst
|
||||
from virtinst import util
|
||||
from virtinst import xmlutil
|
||||
|
||||
from .formats import parser_class
|
||||
|
||||
|
@ -260,7 +260,7 @@ class vmx_parser(parser_class):
|
|||
def _find_keys(prefixes):
|
||||
ret = []
|
||||
for key, value in config.items():
|
||||
for p in util.listify(prefixes):
|
||||
for p in xmlutil.listify(prefixes):
|
||||
if key.startswith(p):
|
||||
ret.append((key, value))
|
||||
break
|
||||
|
|
|
@ -42,7 +42,7 @@ _setup_i18n()
|
|||
_set_libvirt_error_handler()
|
||||
|
||||
|
||||
from virtinst import util
|
||||
from virtinst import xmlutil
|
||||
from virtinst.uri import URI
|
||||
from virtinst.osdict import OSDB
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import libvirt
|
|||
|
||||
from virtcli import CLIConfig
|
||||
|
||||
from . import util
|
||||
from . import xmlutil
|
||||
from .connection import VirtinstConnection
|
||||
from .devices import (Device, DeviceController, DeviceDisk, DeviceGraphics,
|
||||
DeviceInterface, DevicePanic)
|
||||
|
@ -1002,7 +1002,7 @@ class _VirtCLIArgumentStatic(object):
|
|||
VirtCLIArgument. So for an option like --foo bar=X, this
|
||||
checks if we are the parser for 'bar'
|
||||
"""
|
||||
for cliname in [self.cliname] + util.listify(self._aliases):
|
||||
for cliname in [self.cliname] + xmlutil.listify(self._aliases):
|
||||
if "[" in cliname:
|
||||
ret = re.match("^%s$" % cliname.replace(".", r"\."), userstr)
|
||||
else:
|
||||
|
@ -1061,7 +1061,7 @@ class _VirtCLIArgument(object):
|
|||
|
||||
try:
|
||||
if self.propname:
|
||||
util.get_prop_path(inst, self.propname)
|
||||
xmlutil.get_prop_path(inst, self.propname)
|
||||
except AttributeError:
|
||||
raise RuntimeError("programming error: obj=%s does not have "
|
||||
"member=%s" % (inst, self.propname))
|
||||
|
@ -1069,7 +1069,7 @@ class _VirtCLIArgument(object):
|
|||
if self._virtarg.cb:
|
||||
self._virtarg.cb(parser, inst, self.val, self)
|
||||
else:
|
||||
util.set_prop_path(inst, self.propname, self.val)
|
||||
xmlutil.set_prop_path(inst, self.propname, self.val)
|
||||
|
||||
def lookup_param(self, parser, inst):
|
||||
"""
|
||||
|
@ -1097,7 +1097,7 @@ class _VirtCLIArgument(object):
|
|||
return self._virtarg.lookup_cb(parser,
|
||||
inst, self.val, self)
|
||||
else:
|
||||
return util.get_prop_path(inst, self.propname) == self.val
|
||||
return xmlutil.get_prop_path(inst, self.propname) == self.val
|
||||
|
||||
|
||||
def parse_optstr_tuples(optstr):
|
||||
|
@ -1265,7 +1265,7 @@ class VirtCLIParser(metaclass=_InitClass):
|
|||
virtarg = _VirtCLIArgumentStatic(cliname, propname, parent_cliname,
|
||||
*args, **kwargs)
|
||||
if virtarg.cliname in cls.aliases:
|
||||
virtarg.set_aliases(util.listify(cls.aliases.pop(virtarg.cliname)))
|
||||
virtarg.set_aliases(xmlutil.listify(cls.aliases.pop(virtarg.cliname)))
|
||||
cls._virtargs.append(virtarg)
|
||||
|
||||
@classmethod
|
||||
|
@ -1298,7 +1298,7 @@ class VirtCLIParser(metaclass=_InitClass):
|
|||
"""
|
||||
if not cls.guest_propname:
|
||||
return None
|
||||
return util.get_prop_path(obj, cls.guest_propname)
|
||||
return xmlutil.get_prop_path(obj, cls.guest_propname)
|
||||
|
||||
@classmethod
|
||||
def prop_is_list(cls, obj):
|
||||
|
@ -1319,7 +1319,7 @@ class VirtCLIParser(metaclass=_InitClass):
|
|||
self.optstr = optstr
|
||||
self.guest = guest
|
||||
self.optdict = _parse_optstr_to_dict(self.optstr,
|
||||
self._virtargs, util.listify(self.remove_first)[:])
|
||||
self._virtargs, xmlutil.listify(self.remove_first)[:])
|
||||
|
||||
def _clearxml_cb(self, inst, val, virtarg):
|
||||
"""
|
||||
|
@ -1360,10 +1360,10 @@ class VirtCLIParser(metaclass=_InitClass):
|
|||
num = int(reg.groups()[0])
|
||||
|
||||
if can_edit:
|
||||
while len(util.get_prop_path(inst, list_propname)) < (num + 1):
|
||||
util.get_prop_path(inst, list_propname).add_new()
|
||||
while len(xmlutil.get_prop_path(inst, list_propname)) < (num + 1):
|
||||
xmlutil.get_prop_path(inst, list_propname).add_new()
|
||||
try:
|
||||
return util.get_prop_path(inst, list_propname)[num]
|
||||
return xmlutil.get_prop_path(inst, list_propname)[num]
|
||||
except IndexError:
|
||||
if not can_edit:
|
||||
return None
|
||||
|
@ -1433,7 +1433,7 @@ class VirtCLIParser(metaclass=_InitClass):
|
|||
try:
|
||||
objs = self._parse(inst is None and self.guest or inst)
|
||||
if new_object:
|
||||
for obj in util.listify(objs):
|
||||
for obj in xmlutil.listify(objs):
|
||||
if validate:
|
||||
obj.validate()
|
||||
|
||||
|
@ -1442,7 +1442,7 @@ class VirtCLIParser(metaclass=_InitClass):
|
|||
else:
|
||||
self.guest.add_child(obj)
|
||||
|
||||
ret += util.listify(objs)
|
||||
ret += xmlutil.listify(objs)
|
||||
except Exception as e:
|
||||
logging.debug("Exception parsing inst=%s optstr=%s",
|
||||
inst, self.optstr, exc_info=True)
|
||||
|
@ -1460,7 +1460,7 @@ class VirtCLIParser(metaclass=_InitClass):
|
|||
Used only by virt-xml --edit lookups
|
||||
"""
|
||||
ret = []
|
||||
objlist = util.listify(self.lookup_prop(self.guest))
|
||||
objlist = xmlutil.listify(self.lookup_prop(self.guest))
|
||||
|
||||
try:
|
||||
for inst in objlist:
|
||||
|
@ -1542,7 +1542,7 @@ class ParserCheck(VirtCLIParser):
|
|||
|
||||
def parse_check(checks):
|
||||
# Overwrite this for each parse
|
||||
for optstr in util.listify(checks):
|
||||
for optstr in xmlutil.listify(checks):
|
||||
parser = ParserCheck(optstr)
|
||||
parser.parse(get_global_state())
|
||||
|
||||
|
@ -1752,7 +1752,7 @@ class ParserMemory(VirtCLIParser):
|
|||
###################
|
||||
|
||||
def set_memory_cb(self, inst, val, virtarg):
|
||||
util.set_prop_path(inst, virtarg.propname, int(val) * 1024)
|
||||
xmlutil.set_prop_path(inst, virtarg.propname, int(val) * 1024)
|
||||
|
||||
@classmethod
|
||||
def _init_class(cls, **kwargs):
|
||||
|
@ -1937,7 +1937,7 @@ class ParserCPU(VirtCLIParser):
|
|||
|
||||
def set_feature_cb(self, inst, val, virtarg):
|
||||
policy = virtarg.cliname
|
||||
for feature_name in util.listify(val):
|
||||
for feature_name in xmlutil.listify(val):
|
||||
featureobj = None
|
||||
|
||||
for f in inst.features:
|
||||
|
@ -2398,7 +2398,7 @@ class ParserClock(VirtCLIParser):
|
|||
timerobj = inst.timers.add_new()
|
||||
timerobj.name = tname
|
||||
|
||||
util.set_prop_path(timerobj, propname, val)
|
||||
xmlutil.set_prop_path(timerobj, propname, val)
|
||||
|
||||
def timer_find_inst_cb(self, *args, **kwargs):
|
||||
cliarg = "timer" # timer[0-9]*
|
||||
|
@ -3492,7 +3492,7 @@ class ParserMemdev(VirtCLIParser):
|
|||
}
|
||||
|
||||
def set_target_size(self, inst, val, virtarg):
|
||||
util.set_prop_path(inst, virtarg.propname, int(val) * 1024)
|
||||
xmlutil.set_prop_path(inst, virtarg.propname, int(val) * 1024)
|
||||
|
||||
@classmethod
|
||||
def _init_class(cls, **kwargs):
|
||||
|
@ -3839,13 +3839,13 @@ def parse_option_strings(options, guest, instlist, update=False):
|
|||
|
||||
@update: If we are updating an existing guest, like from virt-xml
|
||||
"""
|
||||
instlist = util.listify(instlist)
|
||||
instlist = xmlutil.listify(instlist)
|
||||
if not instlist:
|
||||
instlist = [None]
|
||||
|
||||
ret = []
|
||||
for parserclass in VIRT_PARSERS:
|
||||
optlist = util.listify(getattr(options, parserclass.cli_arg_name))
|
||||
optlist = xmlutil.listify(getattr(options, parserclass.cli_arg_name))
|
||||
if not optlist:
|
||||
continue
|
||||
|
||||
|
@ -3858,7 +3858,7 @@ def parse_option_strings(options, guest, instlist, update=False):
|
|||
for optstr in optlist:
|
||||
parserobj = parserclass(optstr, guest=guest)
|
||||
parseret = parserobj.parse(inst, validate=not update)
|
||||
ret += util.listify(parseret)
|
||||
ret += xmlutil.listify(parseret)
|
||||
|
||||
return ret
|
||||
|
||||
|
@ -3871,7 +3871,7 @@ def check_option_introspection(options):
|
|||
for parserclass in _get_completer_parsers():
|
||||
if not hasattr(options, parserclass.cli_arg_name):
|
||||
continue
|
||||
optlist = util.listify(getattr(options, parserclass.cli_arg_name))
|
||||
optlist = xmlutil.listify(getattr(options, parserclass.cli_arg_name))
|
||||
if not optlist:
|
||||
continue
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import libvirt
|
|||
|
||||
from . import generatename
|
||||
from . import progress
|
||||
from . import util
|
||||
from . import xmlutil
|
||||
from .guest import Guest
|
||||
from .devices import DeviceInterface
|
||||
from .devices import DeviceDisk
|
||||
|
@ -114,7 +114,7 @@ class Cloner(object):
|
|||
# Paths to use for the new disk locations
|
||||
def set_clone_paths(self, paths):
|
||||
disklist = []
|
||||
for path in util.listify(paths):
|
||||
for path in xmlutil.listify(paths):
|
||||
try:
|
||||
device = DeviceDisk.DEVICE_DISK
|
||||
if not path:
|
||||
|
@ -149,7 +149,7 @@ class Cloner(object):
|
|||
|
||||
# MAC address for the new guest clone
|
||||
def set_clone_macs(self, mac):
|
||||
maclist = util.listify(mac)
|
||||
maclist = xmlutil.listify(mac)
|
||||
for m in maclist:
|
||||
DeviceInterface.is_conflict_net(self.conn, m)
|
||||
self._clone_macs = maclist
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
from .device import Device, DeviceSeclabel
|
||||
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
||||
from .. import util
|
||||
from .. import xmlutil
|
||||
|
||||
|
||||
def _set_host_helper(obj, hostparam, portparam, val):
|
||||
|
@ -17,9 +17,9 @@ def _set_host_helper(obj, hostparam, portparam, val):
|
|||
host, port = parse_host(val)
|
||||
if port and not host:
|
||||
host = "127.0.0.1"
|
||||
util.set_prop_path(obj, hostparam, host)
|
||||
xmlutil.set_prop_path(obj, hostparam, host)
|
||||
if port:
|
||||
util.set_prop_path(obj, portparam, port)
|
||||
xmlutil.set_prop_path(obj, portparam, port)
|
||||
|
||||
|
||||
class CharSource(XMLBuilder):
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import libxml2
|
||||
|
||||
from . import util
|
||||
from . import xmlutil
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
||||
|
@ -320,7 +320,7 @@ class _Libxml2API(_XMLBase):
|
|||
return node.content
|
||||
def _node_set_text(self, node, setval):
|
||||
if setval is not None:
|
||||
setval = util.xml_escape(setval)
|
||||
setval = xmlutil.xml_escape(setval)
|
||||
node.setContent(setval)
|
||||
|
||||
def _node_get_property(self, node, propname):
|
||||
|
@ -334,7 +334,7 @@ class _Libxml2API(_XMLBase):
|
|||
prop.unlinkNode()
|
||||
prop.freeNode()
|
||||
else:
|
||||
node.setProp(propname, util.xml_escape(setval))
|
||||
node.setProp(propname, xmlutil.xml_escape(setval))
|
||||
|
||||
def _node_new(self, xpathseg, parentnode):
|
||||
newnode = libxml2.newNode(xpathseg.nodename)
|
||||
|
@ -344,7 +344,7 @@ class _Libxml2API(_XMLBase):
|
|||
def _find_parent_ns():
|
||||
parent = parentnode
|
||||
while parent:
|
||||
for ns in util.listify(parent.nsDefs()):
|
||||
for ns in xmlutil.listify(parent.nsDefs()):
|
||||
if ns.name == xpathseg.nsname:
|
||||
return ns
|
||||
parent = parent.get_parent()
|
||||
|
|
|
@ -14,7 +14,7 @@ import string
|
|||
import textwrap
|
||||
|
||||
from .xmlapi import XMLAPI
|
||||
from . import util
|
||||
from . import xmlutil
|
||||
|
||||
|
||||
# pylint: disable=protected-access
|
||||
|
@ -653,7 +653,7 @@ class XMLBuilder(object):
|
|||
if relative_object_xpath != -1:
|
||||
self._xmlstate.set_relative_object_xpath(relative_object_xpath)
|
||||
for propname in self._all_child_props():
|
||||
for p in util.listify(getattr(self, propname, [])):
|
||||
for p in xmlutil.listify(getattr(self, propname, [])):
|
||||
p._set_xpaths(self._xmlstate.abs_xpath())
|
||||
|
||||
def _set_child_xpaths(self):
|
||||
|
@ -664,7 +664,7 @@ class XMLBuilder(object):
|
|||
"""
|
||||
typecount = {}
|
||||
for propname, xmlprop in self._all_child_props().items():
|
||||
for obj in util.listify(getattr(self, propname)):
|
||||
for obj in xmlutil.listify(getattr(self, propname)):
|
||||
idxstr = ""
|
||||
if not xmlprop.is_single:
|
||||
class_type = obj.__class__
|
||||
|
@ -683,7 +683,7 @@ class XMLBuilder(object):
|
|||
"""
|
||||
self._xmlstate.parse(*args, **kwargs)
|
||||
for propname in self._all_child_props():
|
||||
for p in util.listify(getattr(self, propname, [])):
|
||||
for p in xmlutil.listify(getattr(self, propname, [])):
|
||||
p._parse_with_children(None, self._xmlstate)
|
||||
|
||||
def add_child(self, obj, idx=None):
|
||||
|
@ -793,5 +793,5 @@ class XMLBuilder(object):
|
|||
if key in xmlprops:
|
||||
xmlprops[key]._set_xml(self, self._propstore[key])
|
||||
elif key in childprops:
|
||||
for obj in util.listify(getattr(self, key)):
|
||||
for obj in xmlutil.listify(getattr(self, key)):
|
||||
obj._add_parse_bits(self._xmlstate.xmlapi)
|
||||
|
|
Loading…
Reference in New Issue