[Python-modules-commits] r25401 - in packages/python-docutils/trunk/debian (5 files)
michi at users.alioth.debian.org
michi at users.alioth.debian.org
Mon Aug 5 14:34:44 UTC 2013
Date: Monday, August 5, 2013 @ 14:34:42
Author: michi
Revision: 25401
python-docutils: Two new patches.
* rst2odt_prepstyles-elementtree.diff:
Port rst2odt_prepstyles to ElementTree.
* odt-writer-ascii-filenames.diff:
Use only ASCII filenames in the ODF packages generated by the ODT writer.
Added:
packages/python-docutils/trunk/debian/patches/odt-writer-ascii-filenames.diff
packages/python-docutils/trunk/debian/patches/rst2odt_prepstyles-elementtree.diff
Modified:
packages/python-docutils/trunk/debian/changelog
packages/python-docutils/trunk/debian/control
packages/python-docutils/trunk/debian/patches/series
Modified: packages/python-docutils/trunk/debian/changelog
===================================================================
--- packages/python-docutils/trunk/debian/changelog 2013-08-05 13:09:22 UTC (rev 25400)
+++ packages/python-docutils/trunk/debian/changelog 2013-08-05 14:34:42 UTC (rev 25401)
@@ -16,6 +16,10 @@
instead of the copy shipped with docutils.
- Update information about upstream version control in debian/copyright.
* Change my e-mail host in Uploaders and debian/copyright to @debian.org.
+ * New patch rst2odt_prepstyles-elementtree.diff: Port the rst2odt_prepstyles
+ utility to ElementTree. Drop Recommends: python-lxml. Closes: #714319.
+ * New patch odt-writer-ascii-filenames.diff: Only use ASCII for filenames of
+ images embedded in ODT files, closes: #714317.
[ Dmitry Shachnev ]
* Use dh_python2 instead of deprecated dh_pysupport.
Modified: packages/python-docutils/trunk/debian/control
===================================================================
--- packages/python-docutils/trunk/debian/control 2013-08-05 13:09:22 UTC (rev 25400)
+++ packages/python-docutils/trunk/debian/control 2013-08-05 14:34:42 UTC (rev 25401)
@@ -26,7 +26,6 @@
Recommends: python-imaging,
python-pygments,
libpaper-utils,
- python-lxml,
docutils-doc (= ${source:Version})
Suggests: texlive-latex-recommended, texlive-latex-base, texlive-lang-french, fonts-linuxlibertine | ttf-linux-libertine
Conflicts: python-odtwriter,
@@ -54,8 +53,7 @@
docutils-common (= ${source:Version})
Recommends: python3-imaging,
python3-pygments,
- libpaper-utils,
- python3-lxml
+ libpaper-utils
Conflicts: python-docutils (<< 0.7-3~),
python-odtwriter,
docutils-writer-odt
Added: packages/python-docutils/trunk/debian/patches/odt-writer-ascii-filenames.diff
===================================================================
--- packages/python-docutils/trunk/debian/patches/odt-writer-ascii-filenames.diff (rev 0)
+++ packages/python-docutils/trunk/debian/patches/odt-writer-ascii-filenames.diff 2013-08-05 14:34:42 UTC (rev 25401)
@@ -0,0 +1,35 @@
+Description: Use only ASCII filenames in the ODF packages generated by the ODT writer
+ The odf_odt writer embeds images in its output files and uses the
+ original filenames as part of the embedded filenames. Since the
+ OpenDocument standard does not specify the filename charset, recode to
+ ASCII (dropping non-representable characters) to be on the safe side.
+ This patch also removes an invalid assumption about the encoding
+ used internally by the interpreter, which has caused Debian bug
+ #714317.
+Author: Michael Schutte <michi at debian.org>
+Bug-Debian: http://bugs.debian.org/714317
+Forwarded: https://sourceforge.net/p/docutils/patches/113/
+Last-Update: 2013-08-05
+
+--- a/docutils/writers/odf_odt/__init__.py
++++ b/docutils/writers/odf_odt/__init__.py
+@@ -595,8 +595,7 @@
+ continue
+ try:
+ # encode/decode
+- destination1 = destination.decode('latin-1').encode('utf-8')
+- zfile.write(source, destination1)
++ zfile.write(source, destination)
+ except OSError, e:
+ self.document.reporter.warning(
+ "Can't open file %s." % (source, ))
+@@ -2076,7 +2075,8 @@
+ else:
+ self.image_count += 1
+ filename = os.path.split(source)[1]
+- destination = 'Pictures/1%08x%s' % (self.image_count, filename, )
++ destination = 'Pictures/1%08x_%s' % (self.image_count,
++ filename.encode("ascii", "ignore"))
+ if source.startswith('http:'):
+ try:
+ imgfile = urllib2.urlopen(source)
Added: packages/python-docutils/trunk/debian/patches/rst2odt_prepstyles-elementtree.diff
===================================================================
--- packages/python-docutils/trunk/debian/patches/rst2odt_prepstyles-elementtree.diff (rev 0)
+++ packages/python-docutils/trunk/debian/patches/rst2odt_prepstyles-elementtree.diff 2013-08-05 14:34:42 UTC (rev 25401)
@@ -0,0 +1,65 @@
+Description: Port rst2odt_prepstyles to ElementTree
+ rst2odt_prepstyles uses lxml to parse, modify and write XML.
+ Use ElementTree, which is shipped with Python >= 2.5, in place of lxml.
+Bug-Debian: http://bugs.debian.org/714319
+Author: Michael Schutte <michi at debian.org>
+Forwarded: https://sourceforge.net/p/docutils/patches/114/
+Last-Update: 2013-08-05
+
+--- a/tools/rst2odt_prepstyles.py
++++ b/tools/rst2odt_prepstyles.py
+@@ -12,7 +12,15 @@
+ #
+ # Author: Michael Schutte <michi at uiae.at>
+
+-from lxml import etree
++try:
++ from xml.etree import ElementTree as etree
++except ImportError, e:
++ try:
++ from elementtree import ElementTree as etree
++ except ImportError, e:
++ raise ImportError('Missing an implementation of ElementTree. ' \
++ 'Please install either Python >= 2.5 or ElementTree.')
++
+ import sys
+ import zipfile
+ from tempfile import mkstemp
+@@ -27,12 +35,22 @@
+ def prepstyle(filename):
+
+ zin = zipfile.ZipFile(filename)
+- styles = zin.read("styles.xml")
+-
+- root = etree.fromstring(styles)
+- for el in root.xpath("//style:page-layout-properties",
+- namespaces=NAMESPACES):
+- for attr in el.attrib:
++ styles = zin.open("styles.xml")
++
++ root = None
++ # some extra effort to preserve namespace prefixes
++ for event, elem in etree.iterparse(styles, events=("start", "start-ns")):
++ if event == "start-ns":
++ etree.register_namespace(elem[0], elem[1])
++ elif event == "start":
++ if root is None:
++ root = elem
++
++ styles.close()
++
++ for el in root.findall(".//style:page-layout-properties",
++ namespaces=NAMESPACES):
++ for attr in el.attrib.keys():
+ if attr.startswith("{%s}" % NAMESPACES["fo"]):
+ del el.attrib[attr]
+
+@@ -42,7 +60,7 @@
+
+ for item in zin.infolist():
+ if item.filename == "styles.xml":
+- zout.writestr(item, etree.tostring(root))
++ zout.writestr(item, etree.tostring(root, encoding="UTF-8"))
+ else:
+ zout.writestr(item, zin.read(item.filename))
+
Modified: packages/python-docutils/trunk/debian/patches/series
===================================================================
--- packages/python-docutils/trunk/debian/patches/series 2013-08-05 13:09:22 UTC (rev 25400)
+++ packages/python-docutils/trunk/debian/patches/series 2013-08-05 14:34:42 UTC (rev 25401)
@@ -9,3 +9,5 @@
test-sys-path.diff
move-data-to-usr-share.diff
no-local-roman.diff
+rst2odt_prepstyles-elementtree.diff
+odt-writer-ascii-filenames.diff
More information about the Python-modules-commits
mailing list