[PATCH eac] remove namespaces in the string generated for items attribute

Guillaume Vandevelde guillaume.vandevelde at logilab.fr
Thu Sep 5 10:16:52 CEST 2019


# HG changeset patch
# User Guillaume Vandevelde <gvandevelde at logilab.fr>
# Date 1565270303 -7200
#      Thu Aug 08 15:18:23 2019 +0200
# Node ID 23b2a95297e707d62a235f20324445e8ae255c06
# Parent  268a347314f17a04559a48d3bd851863cb92e158
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 23b2a95297e7
remove namespaces in the string generated for items attribute

diff -r 268a347314f1 -r 23b2a95297e7 cubicweb_eac/dataimport.py
--- a/cubicweb_eac/dataimport.py	Thu Sep 05 10:10:32 2019 +0200
+++ b/cubicweb_eac/dataimport.py	Thu Aug 08 15:18:23 2019 +0200
@@ -21,6 +21,7 @@
 import copy
 import json
 import datetime
+import re
 from functools import wraps, partial
 import inspect
 import logging
@@ -343,12 +344,15 @@
             for child in self._elem_findall(list_elem, 'eac:item'):
                 child.tag = 'li'
             values.append(list_elem)
-        return u"\n".join(
+        result = u"\n".join(
             etree.tostring(
                 item, encoding=text_type,
                 method='html').strip()
             for item in values
             if len(item) != 0 or item.text)
+        filtered = [e for e in re.split(r'xmlns\S*\"', result)
+                    if not e.startswith('xmlns')]
+        return u"".join(filtered)
 
     def record_visited(self, elem, extentity):
         assert extentity.extid, extentity
diff -r 268a347314f1 -r 23b2a95297e7 test/test_dataimport.py
--- a/test/test_dataimport.py	Thu Sep 05 10:10:32 2019 +0200
+++ b/test/test_dataimport.py	Thu Aug 08 15:18:23 2019 +0200
@@ -316,16 +316,14 @@
                                           u"L'inspecteur Canardo"])
               ]),
               'text_format': set([u'text/html']),
-              'items': set([u'<ul xmlns="urn:isbn:1-931666-33-4" '
-                            u'xmlns:xlink="http://www.w3.org/1999'
-                            u'/xlink">\n\t    <li>\n\t      <span style="font-       '
-                            u'style:italic">1450-1950\n\t      </span>\n\t      '
-                            u'(1929)\n\t    </li>\n\t    <li>\n\t      <span '
-                            u'style="font-style:italic">Globe\n\t      '
-                            u'Gliding\n\t      </span>\n\t      (1930)\n\t    '
-                            u'</li>\n\t    <li>\n\t      <span style="font-'
-                            u'       style:italic">Gems\n\t      </span>\n\t'
-                            u'      (1931)\n\t    </li>\n\t  </ul>']),
+              'items': set([u'<ul  >\n\t    <li>\n\t      <span style="font-'
+                            u'       style:italic">1450-1950\n\t      </span'
+                            u'>\n\t      (1929)\n\t    </li>\n\t    <li>\n\t'
+                            u'      <span style="font-style:italic">Globe\n\t'
+                            u'      Gliding\n\t      </span>\n\t      (1930)\n\t'
+                            u'    </li>\n\t    <li>\n\t      <span style="fo'
+                            u'nt-       style:italic">Gems\n\t      </span'
+                            u'>\n\t      (1931)\n\t    </li>\n\t  </ul>']),
               'items_format': set([u'text/html']),
               'history_agent': set(['authorityrecord-FRAD033_EAC_00001']),
               },



More information about the saem-devel mailing list