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
5fe752bc
Commit
5fe752bc
authored
Oct 27, 2009
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Append position in xpath expression when value of id attribute is not unique
parent
3bcf915d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
ERP5Diff.py
ERP5Diff.py
+9
-6
README
README
+6
-6
No files found.
ERP5Diff.py
View file @
5fe752bc
...
...
@@ -238,10 +238,8 @@ class ERP5Diff:
id_list
=
[]
for
attr_map
in
(
element1
.
attrib
,
element2
.
attrib
):
for
name
,
value
in
attr_map
.
items
():
if
name
==
'id'
:
id_list
.
append
(
value
)
break
if
'id'
in
attr_map
:
id_list
.
append
(
attr_map
[
'id'
])
if
len
(
id_list
)
==
0
:
return
True
...
...
@@ -283,7 +281,7 @@ class ERP5Diff:
def
_checkEmptiness
(
self
,
element
):
"""
Check if an element has
child values.
Check if an element has
Element or Text nodes
"""
for
child
in
element
:
if
type
(
child
)
==
etree
.
_Element
:
...
...
@@ -327,7 +325,12 @@ class ERP5Diff:
if
id_val
is
not
None
:
# If an attribute 'id' is present, uses the attribute for convenience.
path_list
.
append
(
"%s[@id='%s']"
%
(
element
.
tag
,
id_val
))
position_predicate
=
''
len_all_similar_sibling
=
len
(
element
.
xpath
(
'../*[@id = "%s"]'
%
id_val
))
if
len_all_similar_sibling
>
1
:
position
=
len_all_similar_sibling
-
element
.
xpath
(
'count(following-sibling::%s[@id = "%s"])'
%
(
element
.
tag
,
id_val
)
)
position_predicate
=
'[%i]'
%
position
path_list
.
append
(
"%s[@id='%s']%s"
%
(
element
.
tag
,
id_val
,
position_predicate
,))
# Increase the count, for a case where other elements with the same tag name do not have
# 'id' attrib.
count_map
[
element
.
tag
]
+=
1
...
...
README
View file @
5fe752bc
...
...
@@ -145,7 +145,7 @@ ERP5Diff Usage and its output example
<xupdate:update select="/object[@id='313730']/description">description1 --- $sdfrç_sdfsçdf_oisfsopf</xupdate:update>
<xupdate:update select="/object[@id='313730']/language/attribute::type">None</xupdate:update>
<xupdate:update select="/object[@id='313730']/language"/>
<xupdate:remove select="/object[@id='313730']/workflow_action[@id='edit_workflow']"/>
<xupdate:remove select="/object[@id='313730']/workflow_action[@id='edit_workflow']
[2]
"/>
</xupdate:modifications>
5. update two elements includes some symbols
...
...
@@ -208,8 +208,8 @@ ERP5Diff Usage and its output example
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/object[@id='313730']/workflow_action[@id='edit_workflow']/time">2009/08/28 19:12:40.905 GMT+9</xupdate:update>
<xupdate:update select="/object[@id='313730']/workflow_action[@id='edit_workflow']/time">2009/08/28 19:12:40.910 GMT+9</xupdate:update>
<xupdate:update select="/object[@id='313730']/workflow_action[@id='edit_workflow']
[2]
/time">2009/08/28 19:12:40.905 GMT+9</xupdate:update>
<xupdate:update select="/object[@id='313730']/workflow_action[@id='edit_workflow']
[3]
/time">2009/08/28 19:12:40.910 GMT+9</xupdate:update>
</xupdate:modifications>
7. insert and remove elements
...
...
@@ -637,9 +637,9 @@ does not work as bellow example. This is a known bug.
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/object[@id='313730']/workflow_action[2]/time">2009/08/29 19:12:34.432 GMT+9</xupdate:update>
<xupdate:update select="/object[@id='313730']/workflow_action[3]/time">2009/08/30 19:12:34.434 GMT+9</xupdate:update>
<xupdate:update select="/object[@id='313730']/workflow_action[4]/time">2009/08/31 19:12:34.436 GMT+9</xupdate:update>
<xupdate:update select="/object[@id='313730']/workflow_action[
@id='edit_workflow'][
2]/time">2009/08/29 19:12:34.432 GMT+9</xupdate:update>
<xupdate:update select="/object[@id='313730']/workflow_action[
@id='edit_workflow'][
3]/time">2009/08/30 19:12:34.434 GMT+9</xupdate:update>
<xupdate:update select="/object[@id='313730']/workflow_action[
@id='edit_workflow'][
4]/time">2009/08/31 19:12:34.436 GMT+9</xupdate:update>
</xupdate:modifications>
22. Modify attributes of sequencial objects
...
...
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