Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5diff
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
erp5diff
Commits
1ba251e9
Commit
1ba251e9
authored
Jan 22, 2008
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use empty namespace for Attribute nodes
parent
bba61e96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
ERP5Diff.py
ERP5Diff.py
+16
-14
No files found.
ERP5Diff.py
View file @
1ba251e9
...
...
@@ -25,12 +25,14 @@ try:
from
Ft.Xml.Domlette
import
NonvalidatingReader
,
PrettyPrint
parseString
=
NonvalidatingReader
.
parseString
from
Ft.Xml.Domlette
import
implementation
from
Ft.Xml
import
EMPTY_NAMESPACE
def
getDOMImplementation
():
return
implementation
except
ImportError
:
from
xml.dom.minidom
import
parse
,
parseString
from
xml.dom.minidom
import
getDOMImplementation
from
xml.dom.ext
import
PrettyPrint
EMPTY_NAMESPACE
=
None
import
sys
import
getopt
...
...
@@ -110,10 +112,10 @@ class ERP5Diff:
createElement
=
self
.
_result
.
createElementNS
createTextNode
=
self
.
_result
.
createTextNode
append_element
=
createElement
(
self
.
_ns
,
'xupdate:append'
)
append_element
.
setAttributeNS
(
self
.
_ns
,
'select'
,
path
)
append_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'select'
,
path
)
for
name
,
val
in
dict
.
iteritems
():
attr_element
=
createElement
(
self
.
_ns
,
'xupdate:attribute'
)
attr_element
.
setAttributeNS
(
self
.
_ns
,
'name'
,
name
)
attr_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'name'
,
name
)
text_node
=
createTextNode
(
val
)
attr_element
.
appendChild
(
text_node
)
append_element
.
appendChild
(
attr_element
)
...
...
@@ -126,7 +128,7 @@ class ERP5Diff:
root
=
self
.
_getResultRoot
()
createElement
=
self
.
_result
.
createElementNS
remove_element
=
createElement
(
self
.
_ns
,
'xupdate:remove'
)
remove_element
.
setAttributeNS
(
self
.
_ns
,
'select'
,
self
.
_concatPath
(
path
,
'attribute::'
+
name
))
remove_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'select'
,
self
.
_concatPath
(
path
,
'attribute::'
+
name
))
root
.
appendChild
(
remove_element
)
def
_xupdateUpdateAttribute
(
self
,
name
,
val
,
path
):
...
...
@@ -137,7 +139,7 @@ class ERP5Diff:
createElement
=
self
.
_result
.
createElementNS
createTextNode
=
self
.
_result
.
createTextNode
update_element
=
createElement
(
self
.
_ns
,
'xupdate:update'
)
update_element
.
setAttributeNS
(
self
.
_ns
,
'select'
,
self
.
_concatPath
(
path
,
'attribute::'
+
name
))
update_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'select'
,
self
.
_concatPath
(
path
,
'attribute::'
+
name
))
text_node
=
createTextNode
(
val
)
update_element
.
appendChild
(
text_node
)
root
.
appendChild
(
update_element
)
...
...
@@ -150,7 +152,7 @@ class ERP5Diff:
createElement
=
self
.
_result
.
createElementNS
createTextNode
=
self
.
_result
.
createTextNode
rename_element
=
createElement
(
self
.
_ns
,
'xupdate:rename'
)
rename_element
.
setAttributeNS
(
self
.
_ns
,
'select'
,
path
)
rename_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'select'
,
path
)
text_node
=
createTextNode
(
name
)
rename_element
.
appendChild
(
text_node
)
root
.
appendChild
(
rename_element
)
...
...
@@ -162,7 +164,7 @@ class ERP5Diff:
root
=
self
.
_getResultRoot
()
createElement
=
self
.
_result
.
createElementNS
update_element
=
createElement
(
self
.
_ns
,
'xupdate:update'
)
update_element
.
setAttributeNS
(
self
.
_ns
,
'select'
,
path
)
update_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'select'
,
path
)
for
node
in
element
.
childNodes
:
#self._p("node is %s" % repr(node))
clone_node
=
node
.
cloneNode
(
1
)
...
...
@@ -176,7 +178,7 @@ class ERP5Diff:
root
=
self
.
_getResultRoot
()
createElement
=
self
.
_result
.
createElementNS
remove_element
=
createElement
(
self
.
_ns
,
'xupdate:remove'
)
remove_element
.
setAttributeNS
(
self
.
_ns
,
'select'
,
path
)
remove_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'select'
,
path
)
root
.
appendChild
(
remove_element
)
def
_xupdateInsertBefore
(
self
,
element_list
,
path
):
...
...
@@ -187,14 +189,14 @@ class ERP5Diff:
createElement
=
self
.
_result
.
createElementNS
createTextNode
=
self
.
_result
.
createTextNode
insert_element
=
createElement
(
self
.
_ns
,
'xupdate:insert-before'
)
insert_element
.
setAttributeNS
(
self
.
_ns
,
'select'
,
path
)
insert_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'select'
,
path
)
for
element
in
element_list
:
child_element
=
createElement
(
self
.
_ns
,
'xupdate:element'
)
child_element
.
setAttributeNS
(
self
.
_ns
,
'name'
,
element
.
tagName
)
child_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'name'
,
element
.
tagName
)
attr_map
=
element
.
attributes
for
attr
in
attr_map
.
values
():
attr_element
=
createElement
(
self
.
_ns
,
'xupdate:attribute'
)
attr_element
.
setAttributeNS
(
self
.
_ns
,
'name'
,
attr
.
name
)
attr_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'name'
,
attr
.
name
)
text_node
=
createTextNode
(
attr
.
nodeValue
)
attr_element
.
appendChild
(
text_node
)
child_element
.
appendChild
(
attr_element
)
...
...
@@ -212,14 +214,14 @@ class ERP5Diff:
createElement
=
self
.
_result
.
createElementNS
createTextNode
=
self
.
_result
.
createTextNode
append_element
=
createElement
(
self
.
_ns
,
'xupdate:append'
)
append_element
.
setAttributeNS
(
self
.
_ns
,
'select'
,
path
)
append_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'select'
,
path
)
for
element
in
element_list
:
child_element
=
createElement
(
self
.
_ns
,
'xupdate:element'
)
child_element
.
setAttributeNS
(
self
.
_ns
,
'name'
,
element
.
tagName
)
child_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'name'
,
element
.
tagName
)
attr_map
=
element
.
attributes
for
attr
in
attr_map
.
values
():
attr_element
=
createElement
(
self
.
_ns
,
'xupdate:attribute'
)
attr_element
.
setAttributeNS
(
self
.
_ns
,
'name'
,
attr
.
name
)
attr_element
.
setAttributeNS
(
EMPTY_NAMESPACE
,
'name'
,
attr
.
name
)
text_node
=
createTextNode
(
attr
.
nodeValue
)
attr_element
.
appendChild
(
text_node
)
child_element
.
appendChild
(
attr_element
)
...
...
@@ -440,7 +442,7 @@ class ERP5Diff:
if
self
.
_result
is
not
None
:
self
.
_result
.
close
()
self
.
_result
=
impl
.
createDocument
(
self
.
_ns
,
'xupdate:modifications'
,
None
)
attr_version
=
self
.
_result
.
createAttributeNS
(
self
.
_ns
,
'version'
)
attr_version
=
self
.
_result
.
createAttributeNS
(
EMPTY_NAMESPACE
,
'version'
)
attr_version
.
value
=
'1.0'
self
.
_result
.
documentElement
.
setAttributeNodeNS
(
attr_version
)
if
self
.
_testElements
(
old_root_element
,
new_root_element
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment