Commit faeba42b authored by Nicolas Delaby's avatar Nicolas Delaby

Update folder structure of egg

Remove zope.interface dependency
Use regular unittest

No change in API, no bug fix
parent c6791670
...@@ -11,1033 +11,6 @@ Once you have installed erp5diff, you can use "erp5diff" in a shell: ...@@ -11,1033 +11,6 @@ Once you have installed erp5diff, you can use "erp5diff" in a shell:
$ erp5diff old.xml new.xml $ erp5diff old.xml new.xml
See the manpage erp5diff(1) or "erp5diff --help" for more information. See the manpage erp5diff(1) or "erp5diff --help" for more information.
Also, you can use the module ERP5Diff from your Python script.
Do "pydoc ERP5Diff" for more information.
ERP5Diff Usage and its output example
=====================================
1. update the texts of the three elements
>>> from ERP5Diff import ERP5Diff
>>> erp5diff = ERP5Diff()
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description1 --- $sdfr&#231;_sdfs&#231;df_oisfsopf</description>
... <first_name type="string">Kamada</first_name>
... <last_name type="string">Kamada</last_name>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:24.700 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description3 &#231;sdf__sdf&#231;&#231;&#231;_df___&amp;amp;&amp;amp;&#233;]]]&#176;&#176;&#176;&#176;&#176;&#176;</description>
... <first_name type="string">Tatuya</first_name>
... <last_name type="string">Kamada</last_name>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:24.703 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/description">description3 çsdf__sdfççç_df___&amp;amp;&amp;amp;é]]]°°°°°°</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/first_name">Tatuya</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow']/time">2009/08/28 19:12:24.703 GMT+9</xupdate:update>
</xupdate:modifications>
2. update one element
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description2&#233;&#224;@ $*&amp;lt; &amp;lt; -----</description>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description3&#233;&#224;@ $*&amp;lt; &amp;lt; -----</description>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/description">description3éà@ $*&amp;lt; &amp;lt; -----</xupdate:update>
</xupdate:modifications>
3. same
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <title type="string">Tatuya Kamada</title>
... <subject_list type="lines">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;list id="i2"&gt;&lt;/list&gt;&lt;/marshal&gt;</subject_list>
... <first_name type="string">Kamada</first_name>
... <last_name type="string">Tatuya</last_name>
... <workflow_action id="edit_workflow">
... <actor type="string">tatuya</actor>
... <time type="date">2009/08/28 19:12:26.631 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <title type="string">Tatuya Kamada</title>
... <subject_list type="lines">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;list id="i2"&gt;&lt;/list&gt;&lt;/marshal&gt;</subject_list>
... <first_name type="string">Kamada</first_name>
... <last_name type="string">Tatuya</last_name>
... <workflow_action id="edit_workflow">
... <actor type="string">tatuya</actor>
... <time type="date">2009/08/28 19:12:26.631 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0"/>
4. update the texts of the elements and remove an element
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description2&#233;&#224;@ $*&amp;lt; &amp;lt;&amp;lt;&amp;lt; -----</description>
... <language type="string">en</language>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.424 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.432 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description1 --- $sdfr&#231;_sdfs&#231;df_oisfsopf</description>
... <language type="None"/>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.424 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/description">description1 --- $sdfrç_sdfsçdf_oisfsopf</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/language/attribute::type">None</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/language"/>
<xupdate:remove select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][2]"/>
</xupdate:modifications>
5. update two elements includes some symbols
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description2&#233;&#224;@ $*&amp;lt;&amp;lt;-----&amp;gt;&amp;gt;</description>
... <language type="string">jp</language>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description4 sdflkmooo^^^^]]]]]{{{{{{{</description>
... <language type="string">ca</language>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/description">description4 sdflkmooo^^^^]]]]]{{{{{{{</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/language">ca</xupdate:update>
</xupdate:modifications>
6. update two date element which have same id
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.550 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.903 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.907 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.550 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.905 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.910 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][2]/time">2009/08/28 19:12:40.905 GMT+9</xupdate:update>
<xupdate:update select="/erp5/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
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313731">
... <local_role type="tokens" id="tk">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Manager&lt;/string&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_role>
... <local_permission type="tokens" id="Access contents information">&lt;?xml version="1.0"?&gt;</local_permission>
... <local_permission type="tokens" id="Add portal content">&lt;?xml version="1.0"?&gt;</local_permission>
... <local_permission type="tokens" id="View">&lt;?xml version="1.0"?&gt;</local_permission>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313731">
... <local_role type="tokens" id="tatuya">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_role>
... <JohnDoe>Go to the beach</JohnDoe>
... <local_permission type="tokens" id="Access contents information">&lt;?xml version="1.0"?&gt;</local_permission>
... <local_permission type="tokens" id="Add portal content">&lt;?xml version="1.0"?&gt;</local_permission>
... <local_permission type="tokens" id="Manage portal content">&lt;?xml version="1.0"?&gt;</local_permission>
... <local_permission type="tokens" id="View">&lt;?xml version="1.0"?&gt;</local_permission>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/erp5/object[@id='313731']/local_role[@id='tk']"/>
<xupdate:append select="/erp5/object[@id='313731']" child="first()">
<xupdate:element name="local_role"><xupdate:attribute name="type">tokens</xupdate:attribute><xupdate:attribute name="id">tatuya</xupdate:attribute>&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</xupdate:element>
<xupdate:element name="JohnDoe">Go to the beach</xupdate:element>
</xupdate:append>
<xupdate:insert-before select="/erp5/object[@id='313731']/local_permission[@id='View']">
<xupdate:element name="local_permission"><xupdate:attribute name="type">tokens</xupdate:attribute><xupdate:attribute name="id">Manage portal content</xupdate:attribute>&lt;?xml version="1.0"?&gt;</xupdate:element>
</xupdate:insert-before>
</xupdate:modifications>
8. update xml in xml
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313731">
... <local_permission type="tokens" id="View">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Manager&lt;/string&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_permission>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313731">
... <local_permission type="tokens" id="View">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Assignee&lt;/string&gt;&lt;string&gt;Assignor&lt;/string&gt;&lt;string&gt;Associate&lt;/string&gt;&lt;string&gt;Auditor&lt;/string&gt;&lt;string&gt;Author&lt;/string&gt;&lt;string&gt;Manager&lt;/string&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_permission>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313731']/local_permission[@id='View']">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Assignee&lt;/string&gt;&lt;string&gt;Assignor&lt;/string&gt;&lt;string&gt;Associate&lt;/string&gt;&lt;string&gt;Auditor&lt;/string&gt;&lt;string&gt;Author&lt;/string&gt;&lt;string&gt;Manager&lt;/string&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</xupdate:update>
</xupdate:modifications>
9. rename element
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <first_name type="string">Tatuya</first_name>
... <last_name type="string">Kamada</last_name>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <given_name type="string">Tatuya</given_name>
... <family_name type="string">Kamada</family_name>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/erp5/object[@id='313730']/first_name"/>
<xupdate:remove select="/erp5/object[@id='313730']/last_name"/>
<xupdate:append select="/erp5/object[@id='313730']" child="first()">
<xupdate:element name="given_name"><xupdate:attribute name="type">string</xupdate:attribute>Tatuya</xupdate:element>
<xupdate:element name="family_name"><xupdate:attribute name="type">string</xupdate:attribute>Kamada</xupdate:element>
</xupdate:append>
</xupdate:modifications>
10. rename root element
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <id type="string">313730</id>
... <title type="string">Tatuya Kamada</title>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp6>
... <object portal_type="Person" id="313730">
... <id type="string">313730</id>
... <title type="string">Tatuya Kamada</title>
... </object>
... </erp6>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:rename select="/erp5">erp6</xupdate:rename>
</xupdate:modifications>
11. Update one attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_role type="tokens" id="fab">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_role>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_role type="ccc" id="fab">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_role>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/local_role[@id='fab']/attribute::type">ccc</xupdate:update>
</xupdate:modifications>
12. Update two attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_permission attr_a='aaa' type="tokens" id="View">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Assignee&lt;/string&gt;&lt;string&gt;Assignor&lt;/string&gt;&lt;string&gt;Associate&lt;/string&gt;&lt;string&gt;Auditor&lt;/string&gt;&lt;string&gt;Author&lt;/string&gt;&lt;string&gt;Manager&lt;/string&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_permission>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_permission attr_a='ccc' type="ccc" id="View">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Assignee&lt;/string&gt;&lt;string&gt;Assignor&lt;/string&gt;&lt;string&gt;Associate&lt;/string&gt;&lt;string&gt;Auditor&lt;/string&gt;&lt;string&gt;Author&lt;/string&gt;&lt;string&gt;Manager&lt;/string&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_permission>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/local_permission[@id='View']/attribute::attr_a">ccc</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/local_permission[@id='View']/attribute::type">ccc</xupdate:update>
</xupdate:modifications>
13. Update three attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <title attribute_a="aaa" attribute_b="bbb" attribute_c="ccc" type="string">Tatuya Kamada</title>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <title attribute_a="nnn" attribute_b="nnn" attribute_c="nnn" type="string">Tatuya Kamada</title>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/title/attribute::attribute_a">nnn</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/title/attribute::attribute_b">nnn</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/title/attribute::attribute_c">nnn</xupdate:update>
</xupdate:modifications>
14. Remove one attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <first_name attribute_a="aaa" attribute_b="bbb" attribute_c="ccc" type="string">Tatuya</first_name>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <first_name attribute_a="aaa" attribute_b="bbb" type="string">Tatuya</first_name>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/erp5/object[@id='313730']/first_name/attribute::attribute_c"/>
</xupdate:modifications>
15. Remove two attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <first_name attribute_a="aaa" attribute_b="bbb" attribute_c="ccc" type="string">Tatuya</first_name>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <first_name attribute_a="aaa" type="string">Tatuya</first_name>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/erp5/object[@id='313730']/first_name/attribute::attribute_b"/>
<xupdate:remove select="/erp5/object[@id='313730']/first_name/attribute::attribute_c"/>
</xupdate:modifications>
16. Remove three attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <first_name attribute_a="aaa" attribute_b="bbb" attribute_c="ccc" type="string">Tatuya</first_name>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <first_name type="string">Tatuya</first_name>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/erp5/object[@id='313730']/first_name/attribute::attribute_a"/>
<xupdate:remove select="/erp5/object[@id='313730']/first_name/attribute::attribute_b"/>
<xupdate:remove select="/erp5/object[@id='313730']/first_name/attribute::attribute_c"/>
</xupdate:modifications>
17. Append one attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <last_name type="string">Kamada</last_name>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <last_name attribute_a="aaa" type="string">Kamada</last_name>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:append select="/erp5/object[@id='313730']/last_name">
<xupdate:attribute name="attribute_a">aaa</xupdate:attribute>
</xupdate:append>
</xupdate:modifications>
18. Append two attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <last_name type="string">Kamada</last_name>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <last_name attribute_a="aaa" attribute_b="bbb" type="string">Kamada</last_name>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:append select="/erp5/object[@id='313730']/last_name">
<xupdate:attribute name="attribute_a">aaa</xupdate:attribute>
<xupdate:attribute name="attribute_b">bbb</xupdate:attribute>
</xupdate:append>
</xupdate:modifications>
19. Append three attribute
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <last_name type="string">Kamada</last_name>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <last_name attribute_a="aaa" attribute_b="bbb" attribute_c="ccc" type="string">Kamada</last_name>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:append select="/erp5/object[@id='313730']/last_name">
<xupdate:attribute name="attribute_a">aaa</xupdate:attribute>
<xupdate:attribute name="attribute_b">bbb</xupdate:attribute>
<xupdate:attribute name="attribute_c">ccc</xupdate:attribute>
</xupdate:append>
</xupdate:modifications>
20. Remove some elements that have same id
This is an unexpected case for current ERP5Diff alogrithm. So current ERP5Diff
does not work as bellow example. This is a known bug.
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.424 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.432 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.434 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.432 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.430 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.428 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.426 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.424 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.430 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.428 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.426 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][2]"/>
<xupdate:remove select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][3]"/>
<xupdate:remove select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][4]"/>
</xupdate:modifications>
21. Modify two elements that have same id
As well as No.20. This a known bug, too.
>>> old_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.424 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.432 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.434 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.436 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Person" id="313730">
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:34.424 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/29 19:12:34.432 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/30 19:12:34.434 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/31 19:12:34.436 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][2]/time">2009/08/29 19:12:34.432 GMT+9</xupdate:update>
<xupdate:update select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][3]/time">2009/08/30 19:12:34.434 GMT+9</xupdate:update>
<xupdate:update select="/erp5/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
ERP5Diff creates target index from 0 as a XPath string, but according to the
definition of the XPath specification <http://www.w3.org/TR/xpath>, it is wrong.
It should be start from 1. This is a known problem.
>>> old_xml = """
... <erp5>
... <object portal_type="Test">
... <title>A</title>
... </object>
... <object portal_type="Test">
... <title>A</title>
... </object>
... <object portal_type="Test">
... <title>A</title>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Test">
... <title>A</title>
... </object>
... <object portal_type="Test">
... <title>B</title>
... </object>
... <object portal_type="Test">
... <title>C</title>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/erp5/object[2]/title">B</xupdate:update>
<xupdate:update select="/erp5/object[3]/title">C</xupdate:update>
</xupdate:modifications>
23. Modify nodes with Qualified Names
ERP5Diff should create xpath valid expression with correct prefix
>>> old_xml = """
... <erp5>
... <object portal_type="Test">
... <prefix:title xmlns:prefix="http://any_uri">A</prefix:title>
... </object>
... <object portal_type="Test">
... <prefixbis:title xmlns:prefixbis="http://any_uri_bis">A</prefixbis:title>
... </object>
... <object portal_type="Test">
... <againanotherprefix:title xmlns:againanotherprefix="http://any_uri">A</againanotherprefix:title>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Test">
... <anotherprefix:title xmlns:anotherprefix="http://any_uri">A</anotherprefix:title>
... </object>
... <object portal_type="Test">
... <prefix:title xmlns:prefix="http://any_uri" prefix:myattr="anyvalue">B</prefix:title>
... </object>
... <object portal_type="Test">
... <title>A</title>
... </object>
... <erp5:object portal_type="Test" xmlns:erp5="http://www.erp5.org/namespaces/erp5_object">
... <title>B</title>
... </erp5:object>
... <object portal_type="Test">
... <prefix:title xmlns:prefix="http://any_uri">C</prefix:title>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove xmlns:prefixbis="http://any_uri_bis" select="/erp5/object[2]/prefixbis:title"/>
<xupdate:append xmlns:prefix="http://any_uri" select="/erp5/object[2]" child="first()">
<xupdate:element name="prefix:title" namespace="http://any_uri"><xupdate:attribute name="prefix:myattr" namespace="http://any_uri">anyvalue</xupdate:attribute>B</xupdate:element>
</xupdate:append>
<xupdate:remove xmlns:againanotherprefix="http://any_uri" select="/erp5/object[3]/againanotherprefix:title"/>
<xupdate:append select="/erp5/object[3]" child="first()">
<xupdate:element name="title">A</xupdate:element>
</xupdate:append>
<xupdate:insert-after xmlns:erp5="http://www.erp5.org/namespaces/erp5_object" select="/erp5/object[3]">
<xupdate:element name="erp5:object" namespace="http://www.erp5.org/namespaces/erp5_object">
<xupdate:attribute name="portal_type">Test</xupdate:attribute>
<title>B</title>
</xupdate:element>
<xupdate:element name="object">
<xupdate:attribute name="portal_type">Test</xupdate:attribute>
<prefix:title xmlns:prefix="http://any_uri">C</prefix:title>
</xupdate:element>
</xupdate:insert-after>
</xupdate:modifications>
24. Modify nodes with Qualified Names
Work on Attributes specially
>>> old_xml = """
... <erp5>
... <object portal_type="Test">
... <title xmlns:prefix="http://any_uri" prefix:attr="A">A</title>
... </object>
... </erp5>
... """
>>> new_xml = """
... <erp5>
... <object portal_type="Test">
... <title xmlns:prefix="http://any_uri" prefix:attr="B">A</title>
... </object>
... </erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update xmlns:prefix="http://any_uri" select="/erp5/object/title/attribute::prefix:attr">B</xupdate:update>
</xupdate:modifications>
25. Modify nodes with Qualified Names at root level
Work on Attributes specially
>>> old_xml = """
... <erp5:erp5 xmlns:erp5="http://www.erp5.org/namspaces/erp5_object" a="aaa" b="bbb">
... <object portal_type="Test">
... <title xmlns:prefix="http://any_uri" prefix:attr="A">A</title>
... </object>
... </erp5:erp5>
... """
>>> new_xml = """
... <aaa:erp5 xmlns:aaa="http://www.erp5.org/namspaces/aaa" b="bbb" >
... <object portal_type="Test">
... <title xmlns:prefix="http://any_uri" prefix:attr="B">A</title>
... </object>
... </aaa:erp5>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:rename xmlns:aaa="http://www.erp5.org/namspaces/aaa" xmlns:erp5="http://www.erp5.org/namspaces/erp5_object" select="/erp5:erp5">aaa:erp5</xupdate:rename>
<xupdate:remove xmlns:aaa="http://www.erp5.org/namspaces/aaa" select="/aaa:erp5/attribute::a"/>
<xupdate:update xmlns:prefix="http://any_uri" xmlns:aaa="http://www.erp5.org/namspaces/aaa" select="/aaa:erp5/object/title/attribute::prefix:attr">B</xupdate:update>
</xupdate:modifications>
26. Reorder some nodes to the end of list
>>> old_xml = """
... <ul>
... <li>1</li>
... <li>2</li>
... <li>3</li>
... <li>4</li>
... <li>5</li>
... <li>6</li>
... <li>7</li>
... <li>8</li>
... <li>9</li>
... </ul>
... """
>>> new_xml = """
... <ul>
... <li>1</li>
... <li>2</li>
... <li>5</li>
... <li>6</li>
... <li>7</li>
... <li>3</li>
... <li>4</li>
... <li>8</li>
... <li>9</li>
... </ul>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/ul/li[3]"/>
<xupdate:remove select="/ul/li[4]"/>
<xupdate:insert-after select="/ul/li[7]">
<xupdate:element name="li">3</xupdate:element>
<xupdate:element name="li">4</xupdate:element>
</xupdate:insert-after>
</xupdate:modifications>
26. Reorder some nodes from the end of list
>>> old_xml = """
... <ul>
... <li>1</li>
... <li>2</li>
... <li>3</li>
... <li>4</li>
... <li>5</li>
... <li>6</li>
... <li>7</li>
... <li>8</li>
... <li>9</li>
... </ul>
... """
>>> new_xml = """
... <ul>
... <li>1</li>
... <li>2</li>
... <li>7</li>
... <li>8</li>
... <li>3</li>
... <li>4</li>
... <li>5</li>
... <li>6</li>
... <li>9</li>
... </ul>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/ul/li[7]"/>
<xupdate:remove select="/ul/li[8]"/>
<xupdate:insert-after select="/ul/li[2]">
<xupdate:element name="li">7</xupdate:element>
<xupdate:element name="li">8</xupdate:element>
</xupdate:insert-after>
</xupdate:modifications>
27. Reorder some nodes at start
>>> old_xml = """
... <ul>
... <li>1</li>
... <li>2</li>
... <li>3</li>
... <li>4</li>
... <li>5</li>
... <li>6</li>
... <li>7</li>
... <li>8</li>
... <li>9</li>
... </ul>
... """
>>> new_xml = """
... <ul>
... <li>5</li>
... <li>6</li>
... <li>1</li>
... <li>2</li>
... <li>3</li>
... <li>4</li>
... <li>7</li>
... <li>8</li>
... <li>9</li>
... </ul>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/ul/li[5]"/>
<xupdate:remove select="/ul/li[6]"/>
<xupdate:append child="first()">
<xupdate:element name="li">5</xupdate:element>
<xupdate:element name="li">6</xupdate:element>
</xupdate:append>
</xupdate:modifications>
28. Reorder some nodes at the end
>>> old_xml = """
... <ul>
... <li>1</li>
... <li>2</li>
... <li>3</li>
... <li>4</li>
... <li>5</li>
... <li>6</li>
... <li>7</li>
... <li>8</li>
... <li>9</li>
... </ul>
... """
>>> new_xml = """
... <ul>
... <li>1</li>
... <li>4</li>
... <li>5</li>
... <li>6</li>
... <li>7</li>
... <li>8</li>
... <li>9</li>
... <li>2</li>
... <li>3</li>
... </ul>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove select="/ul/li[2]"/>
<xupdate:remove select="/ul/li[3]"/>
<xupdate:insert-after select="/ul/li[9]">
<xupdate:element name="li">2</xupdate:element>
<xupdate:element name="li">3</xupdate:element>
</xupdate:insert-after>
</xupdate:modifications>
29. Delete children with white-space as text nodes
>>> old_xml = """
... <object>
... <local_permission type="tokens" id="View">
... <marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller">
... <marshal:tuple>
... <marshal:string>Assignee</marshal:string>
... <marshal:string>Assignor</marshal:string>
... </marshal:tuple>
... </marshal:marshal>
... </local_permission>
... </object>
... """
>>> new_xml = """
... <object>
... <local_permission type="tokens" id="View">
... <marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller">
... <marshal:tuple>
... </marshal:tuple>
... </marshal:marshal>
... </local_permission>
... </object>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove xmlns:marshal="http://www.erp5.org/namespaces/marshaller" select="/object/local_permission[@id='View']/marshal:marshal/marshal:tuple/marshal:string[1]"/>
<xupdate:remove xmlns:marshal="http://www.erp5.org/namespaces/marshaller" select="/object/local_permission[@id='View']/marshal:marshal/marshal:tuple/marshal:string[2]"/>
</xupdate:modifications>
29Bis. Delete childrens with auto-closing nodes
>>> old_xml = """
... <object>
... <local_permission type="tokens" id="View">
... <marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller">
... <marshal:tuple>
... <marshal:string>Assignee</marshal:string>
... <marshal:string>Assignor</marshal:string>
... </marshal:tuple>
... </marshal:marshal>
... </local_permission>
... </object>
... """
>>> new_xml = """
... <object>
... <local_permission type="tokens" id="View">
... <marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller">
... <marshal:tuple/>
... </marshal:marshal>
... </local_permission>
... </object>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove xmlns:marshal="http://www.erp5.org/namespaces/marshaller" select="/object/local_permission[@id='View']/marshal:marshal/marshal:tuple/marshal:string[1]"/>
<xupdate:remove xmlns:marshal="http://www.erp5.org/namespaces/marshaller" select="/object/local_permission[@id='View']/marshal:marshal/marshal:tuple/marshal:string[2]"/>
</xupdate:modifications>
30. Replace a node by another one following by a modification
>>> old_xml = """
... <resource reference="Product Ballon de Plage a5962z">
... <title>Ballon de Plage</title>
... <reference>a5962z</reference>
... <sale_price>200.250000</sale_price>
... <purchase_price>100.250000</purchase_price>
... <category>ball_size/s4</category>
... <category>ball_size/s5</category>
... <category>colour/black</category>
... <category>colour/white</category>
... <category>type/product</category>
... </resource>
... """
>>> new_xml = """
... <resource reference="Product Ballon de Plage a5962z">
... <title>Ballon de Plage</title>
... <reference>a5962z</reference>
... <sale_price>120.000000</sale_price>
... <ean13>1357913579130</ean13><!--replace purchase_price -->
... <category>ball_size/s4</category>
... <category>ball_size/s6</category><!--first modification to trig the bug -->
... <category>colour/red</category>
... <category>colour/white</category>
... <category>type/product</category>
... </resource>
... """
>>> erp5diff.compare(old_xml, new_xml)
>>> erp5diff.output()
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update select="/resource/sale_price">120.000000</xupdate:update>
<xupdate:remove select="/resource/purchase_price"/>
<xupdate:update select="/resource/category[2]">ball_size/s6</xupdate:update>
<xupdate:update select="/resource/category[3]">colour/red</xupdate:update>
<xupdate:insert-before select="/resource/category[0]">
<xupdate:element name="ean13">1357913579130</xupdate:element>
</xupdate:insert-before>
</xupdate:modifications>
- 2003-12-04, Yoshinori OKUJI <yo@nexedi.com> - 2003-12-04, Yoshinori OKUJI <yo@nexedi.com>
- 2009-09-15, Tatuya Kamada <tatuya@nexedi.com> - 2009-09-15, Tatuya Kamada <tatuya@nexedi.com>
#! /usr/bin/python
##############################################################################
#
# Yoshinori OKUJI <yo@nexedi.com>
#
# Copyright (C) 2003 Nexedi SARL
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ?See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ?02111-1307, USA.
#
##############################################################################
from ERP5Diff import main
main()
\ No newline at end of file
...@@ -5,27 +5,28 @@ from setuptools import setup, find_packages ...@@ -5,27 +5,28 @@ from setuptools import setup, find_packages
import re import re
api_version = re.search(r'\s*__version__\s*=\s*(\S+)', api_version = re.search(r'\s*__version__\s*=\s*(\S+)',
open('ERP5Diff.py').read()).group(1).strip() open('src/ERP5Diff.py').read()).group(1).strip()
revision = 0 revision = 0
version = '%s.%s' % (api_version.replace("'", ''), revision) version = '%s.%s' % (api_version.replace("'", ''), revision)
setup(name="erp5diff", setup(name="erp5diff",
version=version, version=version,
description="XUpdate Generator for ERP5", description="XUpdate Generator for ERP5",
author="Yoshinori OKUJI", author="Yoshinori OKUJI",
author_email="yo@nexedi.com", author_email="yo@nexedi.com",
url="http://www.erp5.org/", url="http://www.erp5.org/",
download_url="http://www.nexedi.org/static/packages/source/erp5diff-%s.tar.gz" % version,
license="GPL", license="GPL",
packages=find_packages(), packages=find_packages('src'),
py_modules=["ERP5Diff"], package_dir={'': 'src'},
scripts=["erp5diff"], entry_points={'console_scripts': ["erp5diff = ERP5Diff:main"]},
data_files=[('share/man/man1', ['erp5diff.1'])], data_files=[('share/man/man1', ['src/erp5diff.1'])],
install_requires=['zope.interface', 'lxml'], install_requires=['lxml'],
classifiers=['License :: OSI Approved :: GNU General Public License (GPL)', classifiers=['License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: OS Independent', 'Operating System :: OS Independent',
'Topic :: Text Processing :: Markup :: XML', 'Topic :: Text Processing :: Markup :: XML',
'Topic :: Utilities'], 'Topic :: Utilities'],
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
test_suite='tests',
) )
from zope import interface
import zope.testing
import unittest
OPTIONFLAGS = (zope.testing.doctest.ELLIPSIS |
zope.testing.doctest.NORMALIZE_WHITESPACE)
def test_suite():
doctests = ('README',)
globs = dict(interface=interface)
return unittest.TestSuite((
zope.testing.doctest.DocFileSuite(doctest,
optionflags=OPTIONFLAGS,
globs=globs,
) for doctest in doctests
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
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