dcallagh-exheres

My personal Exherbo repository
git clone https://code.djc.id.au/git/dcallagh-exheres/
commit 12a5d90451a792ad87dc0faac05e90631bd0b0b1
parent 5b77517d72e1c635bdd4f6845036562e1b77137f
Author: Dan Callaghan <djc@djc.id.au>
Date:   Sun,  6 Feb 2011 21:19:22 +1000

initial exheres for Genshi

Diffstat:
Apackages/dev-python/Genshi/Genshi-0.5.1.exheres-0 | 37+++++++++++++++++++++++++++++++++++++
Apackages/dev-python/Genshi/files/markup-join-iterable.patch | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apackages/dev-python/Genshi/files/markup-join-typeerror.patch | 31+++++++++++++++++++++++++++++++
3 files changed, 153 insertions(+), 0 deletions(-)
diff --git a/packages/dev-python/Genshi/Genshi-0.5.1.exheres-0 b/packages/dev-python/Genshi/Genshi-0.5.1.exheres-0
@@ -0,0 +1,37 @@
+# Copyright 2011 Dan Callaghan <djc@djc.id.au>
+# Distributed under the terms of the GNU General Public License v2
+
+require distutils [ python_dep=2.3 ] pypi
+
+SUMMARY="Python toolkit for stream-based generation of output for the web"
+HOMEPAGE="http://genshi.edgewall.org/"
+DOWNLOADS="ftp://ftp.edgewall.com/pub/genshi/${PNV}.tar.bz2"
+
+LICENCES="BSD"
+SLOT="0"
+PLATFORMS="~amd64 ~x86"
+MYOPTIONS="doc examples"
+
+BUGS_TO="djc@djc.id.au"
+
+RESTRICT="test" # they fail
+
+DEFAULT_SRC_PREPARE_PATCHES=(
+    "${FILES}/markup-join-typeerror.patch"
+    "${FILES}/markup-join-iterable.patch"
+)
+
+src_test() {
+    edo python setup.py test
+}
+
+src_install() {
+    distutils_src_install
+    if option doc ; then
+        dodoc -r doc/*
+    fi
+    if option examples ; then
+        insinto /usr/share/doc/${PNV}
+        doins -r examples
+    fi
+}
diff --git a/packages/dev-python/Genshi/files/markup-join-iterable.patch b/packages/dev-python/Genshi/files/markup-join-iterable.patch
@@ -0,0 +1,85 @@
+Source: Dan Callaghan <djc@djc.id.au>
+Upstream: http://genshi.edgewall.org/ticket/258
+Reason: bug fix
+
+diff -r 66f293fadcc5 -r 2256364c3a98 genshi/_speedups.c
+--- Genshi-0.5.1/genshi/_speedups.c	Sun Aug 31 19:15:36 2008 +1000
++++ Genshi-0.5.1/genshi/_speedups.c	Sun Aug 31 19:19:36 2008 +1000
+@@ -229,40 +229,36 @@
+ static PyObject *
+ Markup_join(PyObject *self, PyObject *args, PyObject *kwds)
+ {
+-    static char *kwlist[] = {"seq", "escape_quotes", 0};
+-    PyObject *seq = NULL, *seq2, *tmp, *tmp2;
++    static char *kwlist[] = {"iterable", "escape_quotes", 0};
++    PyObject *iterable = NULL, *iterator, *iteritem, *seq2, *tmp, *tmp2;
+     char quotes = 1;
+-    int n, i;
+ 
+-    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|b", kwlist, &seq, &quotes)) {
++    if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|b", kwlist, 
++            &iterable, &quotes)) {
+         return NULL;
+     }
+-    if (!PySequence_Check(seq)) {
+-        PyErr_FromString(PyExc_TypeError, "a sequence is required");
++    iterator = PyObject_GetIter(iterable);
++    if (iterator == NULL)
+         return NULL;
+-    }
+-    n = PySequence_Size(seq);
+-    if (n < 0) {
+-        return NULL;
+-    }
+-    seq2 = PyTuple_New(n);
++    seq2 = PyList_New(0);
+     if (seq2 == NULL) {
+         return NULL;
+     }
+-    for (i = 0; i < n; i++) {
+-        tmp = PySequence_GetItem(seq, i);
+-        if (tmp == NULL) {
+-            Py_DECREF(seq2);
+-            return NULL;
+-        }
+-        tmp2 = escape(tmp, quotes);
++    while ((iteritem = PyIter_Next(iterator))) {
++        tmp2 = escape(iteritem, quotes);
++        Py_DECREF(iteritem);
+         if (tmp2 == NULL) {
+             Py_DECREF(seq2);
+             return NULL;
+         }
+-        PyTuple_SET_ITEM(seq2, i, tmp2);
+-        Py_DECREF(tmp);
++        if (PyList_Append(seq2, tmp2) < 0) {
++            Py_DECREF(tmp2);
++            return NULL;
++        }
++        Py_DECREF(tmp2);
+     }
++    if (PyErr_Occurred()) // in PyIter_Next above
++        return NULL;
+     tmp = PyUnicode_Join(self, seq2);
+     Py_DECREF(seq2);
+     if (tmp == NULL)
+diff -r 66f293fadcc5 -r 2256364c3a98 genshi/tests/core.py
+--- Genshi-0.5.1/genshi/tests/core.py	Sun Aug 31 19:15:36 2008 +1000
++++ Genshi-0.5.1/genshi/tests/core.py	Sun Aug 31 19:19:36 2008 +1000
+@@ -136,6 +136,16 @@
+         assert type(markup) is Markup
+         self.assertEquals('foo<br />&lt;bar /&gt;<br /><baz />', markup)
+ 
++    def test_join_iterable(self):
++        """
++        Tests calling Markup.join with an argument which is iterable, but not 
++        a sequence.
++        """
++        markup = Markup('<br />').join(x for x in 
++                ['foo', '<bar />', Markup('<baz />')])
++        assert type(markup) is Markup
++        self.assertEquals('foo<br />&lt;bar /&gt;<br /><baz />', markup)
++
+     def test_join_wrongtype(self):
+         """
+         Tests calling Markup.join with an argument whose type is nonsensical.
diff --git a/packages/dev-python/Genshi/files/markup-join-typeerror.patch b/packages/dev-python/Genshi/files/markup-join-typeerror.patch
@@ -0,0 +1,31 @@
+Source: Dan Callaghan <djc@djc.id.au>
+Upstream: http://genshi.edgewall.org/ticket/258
+Reason: bug fix
+
+diff -r 40ef4b6f2654 -r 66f293fadcc5 genshi/_speedups.c
+--- Genshi-0.5.1/genshi/_speedups.c	Sun Aug 31 19:14:34 2008 +1000
++++ Genshi-0.5.1/genshi/_speedups.c	Sun Aug 31 19:15:36 2008 +1000
+@@ -238,6 +238,7 @@
+         return NULL;
+     }
+     if (!PySequence_Check(seq)) {
++        PyErr_FromString(PyExc_TypeError, "a sequence is required");
+         return NULL;
+     }
+     n = PySequence_Size(seq);
+diff -r 40ef4b6f2654 -r 66f293fadcc5 genshi/tests/core.py
+--- Genshi-0.5.1/genshi/tests/core.py	Sun Aug 31 19:14:34 2008 +1000
++++ Genshi-0.5.1/genshi/tests/core.py	Sun Aug 31 19:15:36 2008 +1000
+@@ -136,6 +136,12 @@
+         assert type(markup) is Markup
+         self.assertEquals('foo<br />&lt;bar /&gt;<br /><baz />', markup)
+ 
++    def test_join_wrongtype(self):
++        """
++        Tests calling Markup.join with an argument whose type is nonsensical.
++        """
++        self.assertRaises(TypeError, lambda: Markup('<br />').join(0.5))
++
+     def test_stripentities_all(self):
+         markup = Markup('&amp; &#106;').stripentities()
+         assert type(markup) is Markup