[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#468624: discover-data: diff for NMU version 2.2008.06.25+nmu1



tags 468624 + pending
thanks

Dear maintainer,

I've prepared an NMU for discover-data (versioned as 2.2008.06.25+nmu1)
and uploaded it to DELAYED/7. Please feel free to tell me if I should
delay it longer.

The patch, which you can find attached, ports the Python scripts shipped
under /usr/share/tools/ to legacy Python APIs, removing the need (and
the dep) of python-xml. Part of the patch is from Ben Hutching (from
what concerns reduce-xml).

A few notes:

- I've tested the new scripts by running the non-shipped Makefile and
  Makefile.update which seem to be the only part of discover-data using
  those scripts

- /usr/share/tools/ is not a terribly good path, wouldn't it be more
  appropriate to ship those scripts under /usr/share/discover-data/ or
  so?

- debian/control still contains a XS-Vcs-Svn which should be turned in
  Vcs-Svn as it is now officially supported by dpkg-dev

I've refrained from doing other changes than the Python porting in the
NMU to ease integration of my patch.

Cheers..

-- 
Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime
diff -Nru discover-data-2.2008.06.25/debian/changelog discover-data-2.2008.06.25+nmu1/debian/changelog
--- discover-data-2.2008.06.25/debian/changelog	2008-06-25 22:42:39.000000000 +0200
+++ discover-data-2.2008.06.25+nmu1/debian/changelog	2009-09-09 13:06:09.000000000 +0200
@@ -1,3 +1,13 @@
+discover-data (2.2008.06.25+nmu1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Drop build-dep on python-xml (deprecated). Port the following Python
+    scripts to legacy python modules (Closes: #468624):
+    - reduce-xml (patch from Ben Hutchings)
+    - merge-lst-to-xml
+
+ -- Stefano Zacchiroli <zack@debian.org>  Wed, 09 Sep 2009 13:01:23 +0200
+
 discover-data (2.2008.06.25) unstable; urgency=low
 
   * Update pci-devices.xml and pci.lst
diff -Nru discover-data-2.2008.06.25/merge-lst-to-xml discover-data-2.2008.06.25+nmu1/merge-lst-to-xml
--- discover-data-2.2008.06.25/merge-lst-to-xml	2006-08-13 03:32:04.000000000 +0200
+++ discover-data-2.2008.06.25+nmu1/merge-lst-to-xml	2009-09-09 13:07:23.000000000 +0200
@@ -4,7 +4,8 @@
 import optparse
 import string
 
-from elementtree import ElementTree, XMLTreeBuilder
+from xml.etree import ElementTree
+from xml.etree.ElementTree import XMLTreeBuilder
 
 class LstParser:
     """Parser for discover 1 device lists.  Once initialized, the
@@ -116,14 +117,14 @@
 
         return False
 
-class TreeBuilderWithComments(XMLTreeBuilder.FancyTreeBuilder):
-    """This class extends ElementTree's FancyTreeBuilder to
+class TreeBuilderWithComments(XMLTreeBuilder):
+    """This class extends ElementTree's to
     parse comments, which no builder in ElementTree seems able
     to do by itself.
     """
 
     def __init__(self):
-        XMLTreeBuilder.FancyTreeBuilder.__init__(self)
+        XMLTreeBuilder.__init__(self)
         self._parser.CommentHandler = self._comment
 
     def _comment(self, data):
diff -Nru discover-data-2.2008.06.25/merge-lst-to-xml.diff discover-data-2.2008.06.25+nmu1/merge-lst-to-xml.diff
--- discover-data-2.2008.06.25/merge-lst-to-xml.diff	1970-01-01 01:00:00.000000000 +0100
+++ discover-data-2.2008.06.25+nmu1/merge-lst-to-xml.diff	2009-09-08 22:19:59.000000000 +0200
@@ -0,0 +1,30 @@
+--- merge-lst-to-xml.orig	2009-09-08 22:11:42.777558468 +0200
++++ merge-lst-to-xml	2009-09-08 22:18:59.330558360 +0200
+@@ -4,7 +4,8 @@
+ import optparse
+ import string
+ 
+-from elementtree import ElementTree, XMLTreeBuilder
++from xml.etree import ElementTree
++from xml.etree.ElementTree import XMLTreeBuilder
+ 
+ class LstParser:
+     """Parser for discover 1 device lists.  Once initialized, the
+@@ -116,14 +117,14 @@
+ 
+         return False
+ 
+-class TreeBuilderWithComments(XMLTreeBuilder.FancyTreeBuilder):
+-    """This class extends ElementTree's FancyTreeBuilder to
++class TreeBuilderWithComments(XMLTreeBuilder):
++    """This class extends ElementTree's to
+     parse comments, which no builder in ElementTree seems able
+     to do by itself.
+     """
+ 
+     def __init__(self):
+-        XMLTreeBuilder.FancyTreeBuilder.__init__(self)
++        XMLTreeBuilder.__init__(self)
+         self._parser.CommentHandler = self._comment
+ 
+     def _comment(self, data):
diff -Nru discover-data-2.2008.06.25/reduce-xml discover-data-2.2008.06.25+nmu1/reduce-xml
--- discover-data-2.2008.06.25/reduce-xml	2005-07-17 14:12:58.000000000 +0200
+++ discover-data-2.2008.06.25+nmu1/reduce-xml	2009-09-09 13:06:39.000000000 +0200
@@ -10,8 +10,6 @@
 import getopt
 import xml.dom
 import xml.dom.minidom
-import xml.dom.ext
-from xml.dom.ext.reader import Sax2
 
 try:
     True
@@ -27,7 +25,6 @@
            "classspec": [],
            "classversion": "",
            "modlistfile": "",
-           "use-minidom": True,
            "debug": False
          }
 
@@ -183,14 +180,7 @@
         bus_info = {}
         for fn in config["filelist"]:
             try:
-                if config["use-minidom"]:
-                    document = xml.dom.minidom.parse(fn)
-                else:
-                    f = open(fn)
-                    reader = Sax2.Reader()
-                    document = reader.fromStream(f)
-                    f.close()
-
+                document = xml.dom.minidom.parse(fn)
                 bus_id = document.documentElement.attributes["bus"].value
             except:
                 sys.stderr.write("warning: couldn't parse %s, skipping.\n"
@@ -257,7 +247,8 @@
                             nnode = data_node.childNodes[0]
                             while len(npath) > 0 and nnode is not None:
                                 while nnode is not None and \
-                                      not nnode.hasAttributes():
+                                        nnode.nodeType != \
+                                        xml.dom.Node.ELEMENT_NODE:
                                     nnode = nnode.nextSibling
                                 if nnode is None:
                                     continue
@@ -318,7 +309,7 @@
         else:
             out_file = open(config["outfile"], "w")
 
-        xml.dom.ext.PrettyPrint(out, out_file)
+        out.writexml(out_file, encoding="UTF-8")
 
     except UsageError, e:
         sys.stderr.write(sys.argv[0] + ": " + str(e) + "\n")

Reply to: