m/: Don't depend on PyXML and use only XML modules that are shipped with python....
authorSebastian Dröge <slomo@circular-chaos.org>
Fri, 21 Mar 2008 12:31:52 +0000 (12:31 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Fri, 21 Mar 2008 12:31:52 +0000 (12:31 +0000)
Original commit message from CVS:
* m4/gst-plugin-docs.m4:
* mangle-tmpl.py:
Don't depend on PyXML and use only XML modules that are shipped
with python. Fixes bug #519635.

ChangeLog
m4/gst-plugin-docs.m4
mangle-tmpl.py

index 72f093a..f22c4cf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-03-21  Sebastian Dröge  <slomo@circular-chaos.org>
+
+       * m4/gst-plugin-docs.m4:
+       * mangle-tmpl.py:
+       Don't depend on PyXML and use only XML modules that are shipped
+       with python. Fixes bug #519635.
+
 2008-03-07  Edward Hervey  <edward.hervey@collabora.co.uk>
 
        * m4/gtk-doc.m4: (GTK_DOC_CHECK): 
index 29ebbd6..a285347 100644 (file)
@@ -1,22 +1,3 @@
-dnl AG_GST_PYXML_CHECK([MINIMUM-PYTHON-VERSION])
-
-AC_DEFUN([AG_GST_PYXML_CHECK],
-[
-  AC_BEFORE([AS_PATH_PYTHON],[$0])dnl find python first
-
-  have_pyxml=no
-  if test "x$PYTHON" != x; then
-    AC_MSG_CHECKING([pyxml])
-    if $PYTHON -c "from xml.dom.ext.reader import Sax2" 2>/dev/null \
-      && $PYTHON -c "from xml.dom.NodeFilter import NodeFilter" 2>/dev/null; then
-      AC_MSG_RESULT(yes)
-      have_pyxml=yes
-    else
-      AC_MSG_RESULT(no)
-    fi
-  fi
-])
-
 dnl AG_GST_PLUGIN_DOCS([MINIMUM-GTK-DOC-VERSION],[MINIMUM-PYTHON-VERSION])
 dnl 
 dnl checks for prerequisites for the common/mangle-tmpl.py script
@@ -25,20 +6,13 @@ dnl used when building the plugin documentation
 AC_DEFUN([AG_GST_PLUGIN_DOCS],
 [
   AC_BEFORE([GTK_DOC_CHECK],[$0])dnl check for gtk-doc first
-
-  if test x$enable_gtk_doc = xyes -a x$have_gtk_doc = xyes; then
-    AG_GST_PYXML_CHECK([$1])
-  fi
+  AC_BEFORE([AS_PATH_PYTHON],[$1])dnl find python first
 
   build_plugin_docs=no
   AC_MSG_CHECKING([whether to build plugin documentation])
   if test x$enable_gtk_doc = xyes -a x$have_gtk_doc = xyes; then
-    if test "x$have_pyxml" != xyes; then
-      AC_MSG_RESULT([no (pyxml not installed)])
-    else
-      build_plugin_docs=yes
-      AC_MSG_RESULT([yes])
-    fi
+    build_plugin_docs=yes
+    AC_MSG_RESULT([yes])
   else
     AC_MSG_RESULT([no (gtk-doc disabled or not available)])
   fi
index d319040..6cb52d7 100644 (file)
@@ -83,42 +83,45 @@ class Tmpl:
         handle.write(self.output())
         handle.close()
 
-from xml.dom.ext.reader import Sax2
-from xml.dom.NodeFilter import NodeFilter
+import xml.dom.minidom
 
 def get_elements(file):
     elements = {}
-    handle = open(file)
-    reader = Sax2.Reader()
-    doc = reader.fromStream(handle)
-    handle.close()
-
-    walker = doc.createTreeWalker(doc.documentElement,
-        NodeFilter.SHOW_ELEMENT, None, 0)
-    while walker.currentNode and walker.currentNode.tagName != 'elements':
-        walker.nextNode()
-        
-    # we're at elements now
-    el = walker.firstChild()
-    while walker.currentNode:
-        element = walker.firstChild()
-        # loop over children of <element>
-        name = None
-        description = None
-        while walker.currentNode:
-            if walker.currentNode.tagName == 'name':
-                name = walker.currentNode.firstChild.data.encode('UTF-8')
-            if walker.currentNode.tagName == 'description':
-                description = walker.currentNode.firstChild.data.encode('UTF-8')
-            if not walker.nextSibling(): break
-        # back up to <element>
-        walker.parentNode()
-        elements[name] = {'description': description}
-
-        if not walker.nextSibling(): break
+    doc = xml.dom.minidom.parse(file)
+
+    elem = None
+    for e in doc.childNodes:
+        if e.nodeType == e.ELEMENT_NODE and e.localName == 'plugin':
+            elem = e
+            break
+    if elem == None:
+        return None
+
+    elem2 = None
+    for e in elem.childNodes:
+        if e.nodeType == e.ELEMENT_NODE and e.localName == 'elements':
+            elem2 = e
+            break
+    if elem2 == None:
+        return None
+
+    elem = elem2
+
+    for e in elem.childNodes:
+        if e.nodeType == e.ELEMENT_NODE and e.localName == 'element':
+            name = None
+            description = None
+
+            for e2 in e.childNodes:
+                if e2.nodeType == e2.ELEMENT_NODE and e2.localName == 'name':
+                    name = e2.childNodes[0].nodeValue.encode("UTF-8")
+                elif e2.nodeType == e2.ELEMENT_NODE and e2.localName == 'description':
+                    description = e2.childNodes[0].nodeValue.encode("UTF-8")
+
+            if name != None and description != None:
+                elements[name] = {'description': description}
 
     return elements
-
         
 def main():
     if not len(sys.argv) == 3: