Commit bf028670 authored by Nicolas Delaby's avatar Nicolas Delaby

Use 4Suite Library instead minidom if avalaible

parent b689249b
...@@ -20,7 +20,11 @@ ...@@ -20,7 +20,11 @@
# #
############################################################################## ##############################################################################
from xml.dom.minidom import parse, parseString, getDOMImplementation from xml.dom.minidom import parseString, getDOMImplementation
try:
from Ft.Xml import Parse as parse
except:
from xml.dom.minidom import parse
import sys import sys
import getopt import getopt
import os import os
...@@ -180,8 +184,7 @@ class ERP5Diff: ...@@ -180,8 +184,7 @@ class ERP5Diff:
child_element = createElement('xupdate:element') child_element = createElement('xupdate:element')
child_element.setAttribute('name', element.tagName) child_element.setAttribute('name', element.tagName)
attr_map = element.attributes attr_map = element.attributes
for i in range(attr_map.length): for attr in attr_map.values():
attr = attr_map.item(i)
attr_element = createElement('xupdate:attribute') attr_element = createElement('xupdate:attribute')
attr_element.setAttribute('name', attr.name) attr_element.setAttribute('name', attr.name)
text_node = createTextNode(attr.nodeValue) text_node = createTextNode(attr.nodeValue)
...@@ -206,8 +209,7 @@ class ERP5Diff: ...@@ -206,8 +209,7 @@ class ERP5Diff:
child_element = createElement('xupdate:element') child_element = createElement('xupdate:element')
child_element.setAttribute('name', element.tagName) child_element.setAttribute('name', element.tagName)
attr_map = element.attributes attr_map = element.attributes
for i in range(attr_map.length): for attr in attr_map.values():
attr = attr_map.item(i)
attr_element = createElement('xupdate:attribute') attr_element = createElement('xupdate:attribute')
attr_element.setAttribute('name', attr.name) attr_element.setAttribute('name', attr.name)
text_node = createTextNode(attr.nodeValue) text_node = createTextNode(attr.nodeValue)
...@@ -232,8 +234,7 @@ class ERP5Diff: ...@@ -232,8 +234,7 @@ class ERP5Diff:
id_list = [] id_list = []
for attr_map in (element1.attributes, element2.attributes): for attr_map in (element1.attributes, element2.attributes):
for i in range(attr_map.length): for attr in attr_map.values():
attr = attr_map.item(i)
if attr.name == 'id': if attr.name == 'id':
id_list.append(attr.nodeValue) id_list.append(attr.nodeValue)
break break
...@@ -252,8 +253,7 @@ class ERP5Diff: ...@@ -252,8 +253,7 @@ class ERP5Diff:
dict_list = [] dict_list = []
for attr_map in (element1.attributes, element2.attributes): for attr_map in (element1.attributes, element2.attributes):
dict = {} dict = {}
for i in range(attr_map.length): for attr in attr_map.values():
attr = attr_map.item(i)
dict[attr.name] = attr.nodeValue dict[attr.name] = attr.nodeValue
dict_list.append(dict) dict_list.append(dict)
dict1, dict2 = dict_list dict1, dict2 = dict_list
...@@ -314,8 +314,7 @@ class ERP5Diff: ...@@ -314,8 +314,7 @@ class ERP5Diff:
# Check if this element has an attribute 'id'. # Check if this element has an attribute 'id'.
id_val = None id_val = None
attr_map = element.attributes attr_map = element.attributes
for i in range(attr_map.length): for attr in attr_map.values():
attr = attr_map.item(i)
if attr.name == 'id': if attr.name == 'id':
id_val = attr.nodeValue id_val = attr.nodeValue
break break
...@@ -444,8 +443,8 @@ class ERP5Diff: ...@@ -444,8 +443,8 @@ class ERP5Diff:
self._testAttributes(old_root_element, new_root_element, '/') self._testAttributes(old_root_element, new_root_element, '/')
self._xupdateUpdateElement(new_root_element, '/') self._xupdateUpdateElement(new_root_element, '/')
finally: finally:
old_doc.unlink() del old_doc
new_doc.unlink() del new_doc
def output(self, file=None): def output(self, file=None):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment