From c9c72c5a861e3baca15feba6709f69b0bb0f836b Mon Sep 17 00:00:00 2001 From: Kevin Mihelich Date: Tue, 12 Aug 2014 23:41:20 +0000 Subject: [PATCH] temporarily add community/docutils --- .../01-rst2odt_prepstyles-elementtree.patch | 68 +++++++++++++++ community/docutils/PKGBUILD | 86 +++++++++++++++++++ community/docutils/python2-docutils.install | 9 ++ 3 files changed, 163 insertions(+) create mode 100644 community/docutils/01-rst2odt_prepstyles-elementtree.patch create mode 100644 community/docutils/PKGBUILD create mode 100644 community/docutils/python2-docutils.install diff --git a/community/docutils/01-rst2odt_prepstyles-elementtree.patch b/community/docutils/01-rst2odt_prepstyles-elementtree.patch new file mode 100644 index 000000000..c26845f60 --- /dev/null +++ b/community/docutils/01-rst2odt_prepstyles-elementtree.patch @@ -0,0 +1,68 @@ +--- a/tools/rst2odt_prepstyles.py ++++ b/tools/rst2odt_prepstyles.py +@@ -12,7 +12,15 @@ + # + # Author: Michael Schutte + +-from lxml import etree ++try: ++ from xml.etree import ElementTree as etree ++except ImportError: ++ try: ++ from elementtree import ElementTree as etree ++ except ImportError: ++ 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)) + +@@ -54,8 +72,8 @@ + def main(): + args = sys.argv[1:] + if len(args) != 1: +- print >> sys.stderr, __doc__ +- print >> sys.stderr, "Usage: %s STYLE_FILE.odt\n" % sys.argv[0] ++ sys.stderr.write(__doc__) ++ sys.stderr.write("\nUsage: %s STYLE_FILE.odt\n" % sys.argv[0]) + sys.exit(1) + filename = args[0] + prepstyle(filename) diff --git a/community/docutils/PKGBUILD b/community/docutils/PKGBUILD new file mode 100644 index 000000000..133a124ef --- /dev/null +++ b/community/docutils/PKGBUILD @@ -0,0 +1,86 @@ +# $Id$ +# Maintainer: Sébastien Luttringer +# Contributor : Ionut Biru +# Contributor: Sergej Pupykin + +# Remove when bumped upstream + +pkgbase=docutils +pkgname=('python-docutils' 'python2-docutils') +pkgver=0.12 +pkgrel=1 +pkgdesc='Set of tools for processing plaintext docs into formats such as HTML, XML, or LaTeX' +arch=('any') +url='http://docutils.sourceforge.net' +license=('custom') +makedepends=('python' 'python2') +source=("http://downloads.sourceforge.net/$pkgbase/$pkgbase-$pkgver.tar.gz" + '01-rst2odt_prepstyles-elementtree.patch') +md5sums=('4622263b62c5c771c03502afa3157768' + '34952e8a50692b628a8aa2dde3072f07') + +build() { + cd $pkgbase-$pkgver + for _p in "$srcdir"/*.patch; do + msg2 "${_p##*/}" + patch -p1 -i "$_p" + done + msg2 python3 + python3 setup.py build --build-lib=build/python + find build/python -type f -exec \ + sed -i '1s,^#! \?/usr/bin/\(env \|\)python$,#!/usr/bin/python3,' {} \; + msg2 python2 + python2 setup.py build --build-lib=build/python2 + find build/python2 -type f -exec \ + sed -i '1s,^#! \?/usr/bin/\(env \|\)python$,#!/usr/bin/python2,' {} \; +} + +check() { + cd $pkgbase-$pkgver + # we need utf locale to valid utf8 tests + export LANG=en_US.UTF-8 + # Disable python3 check + #msg2 'python checks' + #PYTHONPATH="$PWD/build/python/" python3 test3/alltests.py + msg2 'python2 checks' + PYTHONPATH="$PWD/build/python2/" python2 test/alltests.py +} + +package_python-docutils() { + depends=('python') + + cd $pkgbase-$pkgver + python setup.py build --build-lib=build/python \ + install --root="$pkgdir" --optimize=1 + # symlink without .py + for f in "$pkgdir"/usr/bin/*.py; do + ln -s "$(basename $f)" "$pkgdir/usr/bin/$(basename $f .py)" + done + # setup license + install -D -m644 COPYING.txt "$pkgdir/usr/share/licenses/$pkgname/COPYING.txt" + install -D -m644 licenses/python* "$pkgdir/usr/share/licenses/$pkgname/" +} + +package_python2-docutils() { + depends=('python2') + provides=("docutils=$pkgver") + replaces=('docutils') + install=python2-docutils.install + + cd $pkgbase-$pkgver + python2 setup.py build --build-lib=build/python2 \ + install --root="$pkgdir" --optimize=1 + # fix python-docutils conflict + for _f in "$pkgdir"/usr/bin/*.py; do + mv -v "$_f" "${_f%.py}2.py" + done + # symlink without .py + for _f in "$pkgdir"/usr/bin/*.py; do + ln -s "$(basename $_f)" "$pkgdir/usr/bin/$(basename $_f .py)" + done + # setup license + install -D -m644 COPYING.txt "$pkgdir/usr/share/licenses/$pkgname/COPYING.txt" + install -D -m644 licenses/python* "$pkgdir/usr/share/licenses/$pkgname/" +} + +# vim:set ts=2 sw=2 et: diff --git a/community/docutils/python2-docutils.install b/community/docutils/python2-docutils.install new file mode 100644 index 000000000..3e414afa2 --- /dev/null +++ b/community/docutils/python2-docutils.install @@ -0,0 +1,9 @@ +post_upgrade() { + [ $(vercmp '0.8.1-2' "$2") -gt 0 ] && cat <