fixed xml formats (untested)

master 3.7.1.1
idziubenko 3 years ago
parent f125972358
commit 41d9ecd6c4

@ -17,7 +17,7 @@
import sys
import time
import re
from ..cl_xml import xpath
from ..cl_xml import xpath, xml_to_str, str_to_xml_doc
# import xml.dom.minidom
from lxml import etree
from .xml_xfce import xml_xfce
@ -73,8 +73,7 @@ class xml_gconf(xml_xfce):
if not self.text.strip():
self.text = '''<?xml version="1.0"?><gconf></gconf>'''
try:
# self.doc = xml.dom.minidom.parseString(self.text)
self.doc = etree.XML(bytes(bytearray(self.text, encoding='utf-8')))
self.doc = str_to_xml_doc(self.text)
except Exception:
self.setError(_("The template content is not XML"))
return False
@ -160,7 +159,7 @@ class xml_gconf(xml_xfce):
'action="drop")')
self.setError(textError)
return False
if xmlOldNode.getparent():
if xmlNewNode.getparent():
findAttrStr = ""
if attrName:
findAttrStr = "[%s]" % attrName
@ -282,7 +281,7 @@ class xml_gconf(xml_xfce):
else:
return s
data = self.doc.toxml().split("\n")
data = xml_to_str(self.doc).split("\n")
data = [expandStartTabs(x) for x in data if x.strip()]
dataOut = []
z = 0
@ -298,4 +297,6 @@ class xml_gconf(xml_xfce):
z = 2
continue
dataOut.append(data[i])
#TODO test this
dataOut.insert(0, '<?xml version="1.0" encoding="UTF-8"?>\n')
return "\n".join(dataOut)

@ -67,7 +67,7 @@ class xml_gconf_tree(xml_gconf):
'action="drop")')
self.setError(textError)
return False
if xmlOldNode.getparent() is not None:
if xmlNewNode.getparent() is not None:
findAttrStr = ""
if attrName:
findAttrStr = "[%s]" % attrName

@ -15,9 +15,7 @@
# limitations under the License.
import sys
from ..cl_xml import xpath
# import xml.dom.minidom
from lxml import etree
from ..cl_xml import xpath, str_to_xml_doc
from .xml_xfce import xml_xfce
from collections.abc import Iterable
from copy import deepcopy
@ -45,7 +43,8 @@ class xml_xfcepanel(xml_xfce):
</panels>'''
try:
# self.doc = xml.dom.minidom.parseString(self.text)
self.doc = etree.XML(bytes(bytearray(self.text, encoding='utf-8')))
# self.doc = etree.XML(bytes(bytearray(self.text, encoding='utf-8')))
self.doc = str_to_xml_doc(self.text)
except Exception:
self.setError(_("The template content is not XML"))
return False
@ -62,7 +61,6 @@ class xml_xfcepanel(xml_xfce):
xmlNode = xmlNewNode
childNodes = list(xmlNode)
nextOldNode = xmlOldNode
# if xmlNode.nodeType == xmlNode.ELEMENT_NODE:
n = xmlNode
flagArray = False
nValue = ''
@ -88,7 +86,7 @@ class xml_xfcepanel(xml_xfce):
'action="drop")')
self.setError(textError)
return False
if xmlOldNode.getparent() is not None:
if xmlNewNode.getparent() is not None:
findAttrStr = ""
if attrName:
findAttrStr = "[%s]" % attrName

Loading…
Cancel
Save