[packages/python-meld3] new, version 0.6.7

glen glen at pld-linux.org
Sat Mar 9 10:50:50 CET 2013


commit 31c13a87a8d8559c15991ce9c72c9e50aa52fdc7
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sat Mar 9 11:49:49 2013 +0200

    new, version 0.6.7
    
    based on fedora package
    64796bb8b4d77425613368d11fd6c813b08a291b

 python-meld3-0.6.7-missing-src-file.patch | 399 ++++++++++++++++++++++++++++++
 python-meld3.spec                         |  69 ++++++
 2 files changed, 468 insertions(+)
---
diff --git a/python-meld3.spec b/python-meld3.spec
new file mode 100644
index 0000000..6a29801
--- /dev/null
+++ b/python-meld3.spec
@@ -0,0 +1,69 @@
+#
+# Conditional build:
+%bcond_without	tests	# do not perform "make test"
+
+%define 	module	meld3
+Summary:	HTML/XML templating system for Python
+Name:		python-%{module}
+Version:	0.6.7
+Release:	1
+License:	ZPL v2.1
+Group:		Development/Languages
+URL:		http://www.plope.com/software/meld3/
+Source0:	http://pypi.python.org/packages/source/m/meld3/meld3-%{version}.tar.gz
+# Source0-md5:	53e589482029ee84ffac9362db71eabe
+# The current meld3 tarball leaves this out by mistake
+# https://github.com/Supervisor/meld3/raw/0.6.7/meld3/cmeld3.c -- AKA:
+# https://github.com/Supervisor/meld3/raw/bafd959fc2e389f46786a6b3174d50f9963fe967/meld3/cmeld3.c
+Patch0:		%{name}-0.6.7-missing-src-file.patch
+BuildRequires:	python-devel
+BuildRequires:	python-elementtree
+BuildRequires:	rpm-pythonprov
+BuildRequires:	rpmbuild(macros) >= 1.219
+Requires:	python-elementtree
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+meld3 is an HTML/XML templating system for Python 2.3+ which keeps
+template markup and dynamic rendering logic separate from one another.
+See <http://www.entrian.com/PyMeld> for a treatise on the benefits of
+this pattern.
+
+%prep
+%setup -q -n meld3-%{version}
+%patch0 -p1
+
+%build
+export USE_MELD3_EXTENSION_MODULES=True
+CC="%{__cc}" \
+CFLAGS="%{rpmcflags}" \
+%{__python} setup.py build
+
+%if %{with tests}
+%{__python} meld3/test_meld3.py
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+export USE_MELD3_EXTENSION_MODULES=True
+%{__python} setup.py install \
+	--skip-build \
+	--optimize=2 \
+	--root=$RPM_BUILD_ROOT
+
+%py_postclean
+
+%{__rm} $RPM_BUILD_ROOT%{py_sitedir}/meld3/test_*
+
+sed -i s'/^#!.*//' $(find $RPM_BUILD_ROOT/%{py_sitedir}/meld3/ -type f)
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%doc README.txt COPYRIGHT.txt LICENSE.txt CHANGES.txt
+%dir %{py_sitedir}/%{module}
+%{py_sitedir}/%{module}/*.py[co]
+%attr(755,root,root) %{py_sitedir}/meld3/cmeld3.so
+%{py_sitedir}/%{module}-%{version}*.egg-info
diff --git a/python-meld3-0.6.7-missing-src-file.patch b/python-meld3-0.6.7-missing-src-file.patch
new file mode 100644
index 0000000..8aa907f
--- /dev/null
+++ b/python-meld3-0.6.7-missing-src-file.patch
@@ -0,0 +1,399 @@
+diff -up meld3-0.6.7/meld3/cmeld3.c.missing-src-file meld3-0.6.7/meld3/cmeld3.c
+--- meld3-0.6.7/meld3/cmeld3.c.missing-src-file	2011-04-05 14:31:26.229563043 +0200
++++ meld3-0.6.7/meld3/cmeld3.c	2011-04-05 14:30:52.631796235 +0200
+@@ -0,0 +1,395 @@
++#include <Python.h>
++
++/* fprintf(stderr, "%s:%s:%d\n", __FILE__,__FUNCTION__,__LINE__);
++   fflush(stderr); */
++
++static PyObject *PySTR__class__, *PySTR__dict__, *PySTR_children;
++static PyObject *PySTRattrib, *PySTRparent, *PySTR_MELD_ID;
++static PyObject *PySTRtag, *PySTRtext, *PySTRtail, *PySTRstructure;
++static PyObject *PySTRReplace;
++
++static PyObject *emptyattrs, *emptychildren = NULL;
++
++static PyObject*
++bfclone(PyObject *nodes, PyObject *parent)
++{
++    int len, i;
++
++    if (!(PyList_Check(nodes))) {
++	return NULL;
++    }
++
++    len = PyList_Size(nodes);
++
++    if (len < 0) {
++	return NULL;
++    }
++
++    PyObject *L;
++    if (!(L = PyList_New(0))) return NULL;
++
++    for (i = 0; i < len; i++) {
++
++	PyObject *node;
++
++	if (!(node = PyList_GetItem(nodes, i))) {
++	    return NULL;
++	}
++
++	PyObject *klass;
++	PyObject *children;
++	PyObject *text;
++	PyObject *tail;
++	PyObject *tag;
++	PyObject *attrib;
++	PyObject *structure;
++	PyObject *dict;
++	PyObject *newdict;
++	PyObject *newchildren;
++	PyObject *attrib_copy;
++	PyObject *element;
++	int childsize;
++
++	if (!(klass = PyObject_GetAttr(node, PySTR__class__))) return NULL;
++	if (!(dict = PyObject_GetAttr(node, PySTR__dict__))) return NULL;
++
++	if (!(children = PyDict_GetItem(dict, PySTR_children))) return NULL;
++	if (!(tag = PyDict_GetItem(dict, PySTRtag))) return NULL;
++	if (!(attrib = PyDict_GetItem(dict, PySTRattrib))) return NULL;
++
++	if (!(text = PyDict_GetItem(dict, PySTRtext))) {
++	    text = Py_None;
++	}
++	if (!(tail = PyDict_GetItem(dict, PySTRtail))) {
++	    tail = Py_None;
++	}
++	if (!(structure = PyDict_GetItem(dict, PySTRstructure))) {
++	    structure = Py_None;
++	}
++	Py_DECREF(dict);
++
++	if (!(newdict = PyDict_New())) return NULL;
++	if (!(newchildren = PyList_New(0))) return NULL;
++
++	attrib_copy = PyDict_Copy(attrib);
++
++	PyDict_SetItem(newdict, PySTR_children, newchildren);
++        Py_DECREF(newchildren);
++	PyDict_SetItem(newdict, PySTRattrib, attrib_copy);
++        Py_DECREF(attrib_copy);
++	PyDict_SetItem(newdict, PySTRtext, text);
++	PyDict_SetItem(newdict, PySTRtail, tail);
++	PyDict_SetItem(newdict, PySTRtag, tag);
++	PyDict_SetItem(newdict, PySTRstructure, structure);
++	PyDict_SetItem(newdict, PySTRparent, parent);
++    
++	if (!(element = PyInstance_NewRaw(klass, newdict))) {
++	    return NULL;
++	}
++
++        Py_DECREF(newdict);
++	Py_DECREF(klass);
++ 
++	if (PyList_Append(L, element)) {
++	    return NULL;
++	}
++        Py_DECREF(element);
++
++	if (!PyList_Check(children)) return NULL;
++
++	if ((childsize = PyList_Size(children)) < 0) {
++	    return NULL;
++	}
++	else {
++	    if (childsize > 0) {
++		bfclone(children, element);
++	    }
++	}
++    }
++
++    if (PyObject_SetAttr(parent, PySTR_children, L)) return NULL;
++    Py_DECREF(L);
++    return parent;
++
++}
++
++static PyObject*
++bfclonehandler(PyObject *self, PyObject *args)
++{
++    PyObject *node, *parent;
++	
++    if (!PyArg_ParseTuple(args, "OO:clone", &node, &parent)) {
++	return NULL;
++    }
++    
++    PyObject *klass;
++    PyObject *children;
++    PyObject *text;
++    PyObject *tail;
++    PyObject *tag;
++    PyObject *attrib;
++    PyObject *structure;
++    PyObject *dict;
++    PyObject *newdict;
++    PyObject *newchildren;
++    PyObject *attrib_copy;
++    PyObject *element;
++
++    if (!(klass = PyObject_GetAttr(node, PySTR__class__))) return NULL;
++    if (!(dict = PyObject_GetAttr(node, PySTR__dict__))) return NULL;
++    
++    if (!(children = PyDict_GetItem(dict, PySTR_children))) return NULL;
++    if (!(tag = PyDict_GetItem(dict, PySTRtag))) return NULL;
++    if (!(attrib = PyDict_GetItem(dict, PySTRattrib))) return NULL;
++    
++    if (!(text = PyDict_GetItem(dict, PySTRtext))) {
++	text = Py_None;
++    }
++    if (!(tail = PyDict_GetItem(dict, PySTRtail))) {
++	tail = Py_None;
++    }
++    if (!(structure = PyDict_GetItem(dict, PySTRstructure))) {
++	structure = Py_None;
++    }
++
++    Py_DECREF(dict);
++
++    if (!(newdict = PyDict_New())) return NULL;
++    if (!(newchildren = PyList_New(0))) return NULL;
++
++    attrib_copy = PyDict_Copy(attrib);
++
++    PyDict_SetItem(newdict, PySTR_children, newchildren);
++    Py_DECREF(newchildren);
++    PyDict_SetItem(newdict, PySTRattrib, attrib_copy);
++    Py_DECREF(attrib_copy);
++    PyDict_SetItem(newdict, PySTRtext, text);
++    PyDict_SetItem(newdict, PySTRtail, tail);
++    PyDict_SetItem(newdict, PySTRtag, tag);
++    PyDict_SetItem(newdict, PySTRstructure, structure);
++    PyDict_SetItem(newdict, PySTRparent, parent);
++
++    if (!(element = PyInstance_NewRaw(klass, newdict))) return NULL;
++    Py_DECREF(newdict);
++    Py_DECREF(klass);
++
++    PyObject *pchildren;
++    
++    if (parent != Py_None) {
++        if (!(pchildren=PyObject_GetAttr(parent, PySTR_children))) return NULL;
++	if (PyList_Append(pchildren, element)) return NULL;
++        Py_DECREF(pchildren);
++    }
++
++    if (!(PyList_Check(children))) return NULL;
++
++    if (PyList_Size(children) > 0) {
++	if (bfclone(children, element) == NULL) {
++	    return NULL;
++	}
++    }
++    return element;
++    
++}
++
++PyDoc_STRVAR(bfclonehandler_doc,
++"bfclone(node, parent=None)\n			\
++\n\
++Return a clone of the meld3 node named by node (breadth-first).  If parent\n\
++is not None, append the clone to the parent.\n");
++
++static PyObject*
++getiterator(PyObject *node, PyObject *list) {
++    if (PyList_Append(list, node) == -1) {
++	return NULL;
++    }
++    PyObject *children;
++    PyObject *child;
++
++    if (!(children = PyObject_GetAttr(node, PySTR_children))) {
++	return NULL;
++    }
++
++    int len, i;
++    len = PyList_Size(children);
++    if (len < 0) {
++	return NULL;
++    }
++
++    for (i = 0; i < len; i++) {
++	if (!(child = PyList_GetItem(children, i))) {
++	    return NULL;
++	}
++        getiterator(child, list);
++	}
++
++    Py_DECREF(children);
++    return list;
++}
++
++static PyObject*
++getiteratorhandler(PyObject *self, PyObject *args)
++{
++    PyObject *node;
++	
++    if (!PyArg_ParseTuple(args, "O:getiterator", &node)) {
++	return NULL;
++    }
++    PyObject *list;
++    PyObject *result;
++    if (!(list = PyList_New(0))) {
++	return NULL;
++    }
++    result = getiterator(node, list);
++    if (result == NULL) {
++	PyList_SetSlice(list, 0, PyList_GET_SIZE(list), (PyObject *)NULL);
++        Py_DECREF(list);
++    }
++    return result;
++}
++
++PyDoc_STRVAR(getiteratorhandler_doc, 
++"getiterator(node)\n\
++\n\
++Returns an iterator for the node.");
++
++static char* _MELD_ID = "{http://www.plope.com/software/meld3}id";
++/*static PyObject *PySTR_MELD_ID = PyString_FromString(_MELD_ID);*/
++
++static PyObject*
++findmeld(PyObject *node, PyObject *name) {
++    PyObject *attrib, *meldid, *result;
++    if (!(attrib = PyObject_GetAttr(node, PySTRattrib))) return NULL;
++    meldid = PyDict_GetItem(attrib, PySTR_MELD_ID);
++    Py_DECREF(attrib);
++
++    if (meldid != NULL) {
++	int compareresult = PyUnicode_Compare(meldid, name);
++	if (compareresult == 0) {
++            Py_INCREF(node);
++            return node;
++	}
++    }
++
++    int len, i;
++    result = Py_None;
++    PyObject *children = PyObject_GetAttr(node, PySTR_children);
++    len = PyList_Size(children);
++    for (i = 0; i < len; i++) {
++        PyObject *child = PyList_GetItem(children, i);
++        result = findmeld(child, name);
++        if (result != Py_None) {
++            break;
++        }
++    }
++    Py_DECREF(children);
++
++    return result;
++    
++}
++
++static PyObject*
++findmeldhandler(PyObject *self, PyObject *args)
++{
++    PyObject *node, *name, *result;
++	
++    if (!PyArg_ParseTuple(args, "OO:findmeld", &node, &name)) {
++	return NULL;
++    }
++    if (!(result = findmeld(node, name))) return NULL;
++
++    if (result == Py_None) {
++        Py_INCREF(Py_None);
++    }
++
++    return result;
++}
++
++PyDoc_STRVAR(findmeldhandler_doc,
++"findmeld(node, meldid)\n\
++\n\
++Return a meld node or None.\n");
++
++static PyObject*
++contenthandler(PyObject *self, PyObject *args) {
++    PyObject *node, *text, *structure;
++	
++    if (!PyArg_ParseTuple(args, "OOO:content", &node, &text, &structure)) {
++	return NULL;
++    }
++    PyObject *replacel = NULL;
++    PyObject *replace = NULL;
++    PyObject *replacenode  = NULL;
++    PyObject *newchildren  = NULL;
++    PyObject *newdict  = NULL;
++    PyObject *klass  = NULL;
++
++    if (!(klass = PyObject_GetAttr(node, PySTR__class__))) return NULL;
++    if (!(replacel = PyObject_GetAttr(node, PySTRReplace))) return NULL;
++    if (!(replace = PyList_GetItem(replacel, 0))) return NULL;
++    Py_DECREF(replacel);
++
++    PyObject_SetAttr(node, PySTRtext, Py_None);
++
++    if (!(newdict = PyDict_New())) return NULL;
++
++    if (PyDict_SetItem(newdict, PySTRparent, node) == -1) return NULL;
++    if (PyDict_SetItem(newdict, PySTRattrib, emptyattrs) == -1) return NULL;
++    if (PyDict_SetItem(newdict, PySTRtext, text) == -1) return NULL;
++    if (PyDict_SetItem(newdict, PySTRstructure, structure) == -1) return NULL;
++    if (PyDict_SetItem(newdict, PySTRtag, replace) == -1) return NULL;
++    if (PyDict_SetItem(newdict, PySTR_children, emptychildren) == -1) {
++	return NULL;
++    }
++    if (!(replacenode = PyInstance_NewRaw(klass, newdict))) return NULL;
++    Py_DECREF(klass);
++    Py_DECREF(newdict);
++
++    if (!(newchildren = PyList_New(1))) return NULL;
++    PyList_SET_ITEM(newchildren, 0, replacenode);  // steals a reference to rn
++    PyObject_SetAttr(node, PySTR_children, newchildren);
++    Py_DECREF(newchildren);
++    Py_INCREF(Py_None);
++    return Py_None;
++    
++}
++
++PyDoc_STRVAR(contenthandler_doc,
++"content(node, text, structure)\n\
++\n\
++Add a content node to node.");
++
++static PyMethodDef methods[] = {
++    {"bfclone", bfclonehandler, METH_VARARGS, bfclonehandler_doc},
++    {"getiterator", getiteratorhandler, METH_VARARGS, getiteratorhandler_doc},
++    {"findmeld", findmeldhandler, METH_VARARGS, findmeldhandler_doc},
++    {"content", contenthandler, METH_VARARGS, contenthandler_doc},
++    {NULL, NULL}
++};
++
++PyMODINIT_FUNC
++initcmeld3(void) 
++{
++#define DEFINE_STRING(s) \
++    if (!(PySTR##s = PyString_FromString(#s))) return 
++    DEFINE_STRING(__class__); 
++    DEFINE_STRING(__dict__); 
++    DEFINE_STRING(_children);
++    DEFINE_STRING(parent);
++    DEFINE_STRING(tag);
++    DEFINE_STRING(attrib);
++    DEFINE_STRING(text);
++    DEFINE_STRING(tail);
++    DEFINE_STRING(structure);
++    DEFINE_STRING(Replace);
++#undef DEFINE_STRING
++    PySTR_MELD_ID = PyString_FromString(_MELD_ID);
++    if (!PySTR_MELD_ID) {
++	return;
++    }
++    emptyattrs = PyDict_New();
++/*     emptyattrs = PyDictProxy_New(emptyattrs); can't copy a proxy, so... */
++    emptychildren = PyList_New(0);
++    Py_InitModule3("cmeld3", methods,
++		   "C helpers for meld3");
++}
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-meld3.git/commitdiff/31c13a87a8d8559c15991ce9c72c9e50aa52fdc7



More information about the pld-cvs-commit mailing list