rpms/python-meld3/F-7 cmeld3.c, NONE, 1.1 meld3-etree.patch, NONE, 1.1 .cvsignore, 1.3, 1.4 python-meld3.spec, 1.3, 1.4 sources, 1.3, 1.4
Toshio くらとみ (toshio)
fedora-extras-commits at redhat.com
Thu Feb 28 19:54:08 UTC 2008
Author: toshio
Update of /cvs/pkgs/rpms/python-meld3/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21376
Modified Files:
.cvsignore python-meld3.spec sources
Added Files:
cmeld3.c meld3-etree.patch
Log Message:
* Tue Feb 28 2008 Toshio Kuratomi <toshio at fedoraproject.org> 0.6.4-1
- Update to 0.6.4.
- Fix python-2.5 elementtree problem.
--- NEW FILE cmeld3.c ---
#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");
}
meld3-etree.patch:
--- NEW FILE meld3-etree.patch ---
Index: meld3-0.6.4/meld3/meld3.py
===================================================================
--- meld3-0.6.4.orig/meld3/meld3.py
+++ meld3-0.6.4/meld3/meld3.py
@@ -5,21 +5,41 @@ import types
import mimetools
from StringIO import StringIO
-from elementtree.ElementTree import TreeBuilder
-from elementtree.ElementTree import XMLTreeBuilder
-from elementtree.ElementTree import Comment
-from elementtree.ElementTree import ProcessingInstruction
-from elementtree.ElementTree import QName
-from elementtree.ElementTree import _raise_serialization_error
-from elementtree.ElementTree import _namespace_map
-from elementtree.ElementTree import fixtag
-from elementtree.ElementTree import parse as et_parse
-from elementtree.ElementTree import ElementPath
-from elementtree.HTMLTreeBuilder import HTMLParser
-from elementtree.HTMLTreeBuilder import IGNOREEND
-from elementtree.HTMLTreeBuilder import AUTOCLOSE
-from elementtree.HTMLTreeBuilder import is_not_ascii
-
+try:
+ # Try to import the definitions from the python-2.5 locations
+ from xml.etree.ElementTree import TreeBuilder
+except ImportError:
+ # Fallback on elementtree
+ from elementtree.ElementTree import TreeBuilder
+ from elementtree.ElementTree import XMLTreeBuilder
+ from elementtree.ElementTree import Comment
+ from elementtree.ElementTree import ProcessingInstruction
+ from elementtree.ElementTree import QName
+ from elementtree.ElementTree import _raise_serialization_error
+ from elementtree.ElementTree import _namespace_map
+ from elementtree.ElementTree import fixtag
+ from elementtree.ElementTree import parse as et_parse
+ from elementtree.ElementTree import ElementPath
+ from elementtree.HTMLTreeBuilder import HTMLParser
+ from elementtree.HTMLTreeBuilder import IGNOREEND
+ from elementtree.HTMLTreeBuilder import AUTOCLOSE
+ from elementtree.HTMLTreeBuilder import is_not_ascii
+else:
+ from xml.etree.ElementTree import XMLTreeBuilder
+ from xml.etree.ElementTree import Comment
+ from xml.etree.ElementTree import ProcessingInstruction
+ from xml.etree.ElementTree import QName
+ from xml.etree.ElementTree import _raise_serialization_error
+ from xml.etree.ElementTree import _namespace_map
+ from xml.etree.ElementTree import fixtag
+ from xml.etree.ElementTree import parse as et_parse
+ from xml.etree.ElementTree import ElementPath
+ # Elementtree 1.2.6 snpshot 20050316 defines things this way so we might
+ # as well too.
+ from HTMLParser import HTMLParser
+ IGNOREEND = "img", "hr", "meta", "link", "br"
+ AUTOCLOSE = "p", "li", "tr", "th", "td", "head", "body"
+ is_not_ascii = re.compile(eval(r'u"[\u0080-\uffff]"')).search
# replace element factory
def Replace(text, structure=False):
Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/python-meld3/F-7/.cvsignore,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- .cvsignore 18 Oct 2007 22:28:59 -0000 1.3
+++ .cvsignore 28 Feb 2008 19:53:25 -0000 1.4
@@ -1 +1 @@
-meld3-0.6.3.tar.gz
+meld3-0.6.4.tar.gz
Index: python-meld3.spec
===================================================================
RCS file: /cvs/pkgs/rpms/python-meld3/F-7/python-meld3.spec,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- python-meld3.spec 18 Oct 2007 22:28:59 -0000 1.3
+++ python-meld3.spec 28 Feb 2008 19:53:25 -0000 1.4
@@ -1,13 +1,17 @@
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
Summary: An HTML/XML templating system for Python
Name: python-meld3
-Version: 0.6.3
+Version: 0.6.4
Release: 1%{?dist}
License: ZPLv2.0
Group: Development/Languages
URL: http://www.plope.com/software/meld3/
-Source: http://www.plope.com/software/meld3/meld3-%{version}.tar.gz
+Source0: http://www.plope.com/software/meld3/meld3-%{version}.tar.gz
+# 0.6.4 is a bit broken. This file is missing from the tarball.
+Source1: http://svn.supervisord.org/meld3/trunk/meld3/cmeld3.c
+# Fix problems importing python-2.5's elementtree.
+Patch0: meld3-etree.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%if 0%{?fedora} <= 6
@@ -25,14 +29,19 @@
%prep
%setup -q -n meld3-%{version}
+cp %{SOURCE1} meld3/cmeld3.c
+%patch0 -p1 -b .etree
%build
+export USE_MELD3_EXTENSION_MODULES=True
CFLAGS="%{optflags}" %{__python} setup.py build
%install
%{__rm} -rf %{buildroot}
+export USE_MELD3_EXTENSION_MODULES=True
%{__python} setup.py install --skip-build --root %{buildroot}
%{__sed} -i s'/^#!.*//' $( find %{buildroot}/%{python_sitearch}/meld3/ -type f)
+chmod 0755 %{buildroot}/%{python_sitearch}/meld3/cmeld3.so
%clean
%{__rm} -rf %{buildroot}
@@ -40,9 +49,19 @@
%files
%defattr(-,root,root,-)
%doc README.txt COPYRIGHT.txt LICENSE.txt CHANGES.txt
-%{python_sitearch}/meld3/
+%{python_sitearch}/*
%changelog
+* Tue Feb 28 2008 Toshio Kuratomi <toshio at fedoraproject.org> 0.6.4-1
+- Update to 0.6.4.
+- Fix python-2.5 elementtree problem.
+
+* Tue Feb 12 2008 Mike McGrath <mmcgrath at redhat.com> 0.6.3-3
+- Rebuild for gcc43
+
+* Mon Jan 7 2008 Toshio Kuratomi <a.badger at gmail.com> 0.6.3-2
+- Fix include egginfo when created.
+
* Wed Oct 17 2007 Toshio Kuratomi <a.badger at gmail.com> 0.6.3-1
- Update to 0.6.3 (Fix memory leaks).
- Update license tag.
Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/python-meld3/F-7/sources,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- sources 18 Oct 2007 22:28:59 -0000 1.3
+++ sources 28 Feb 2008 19:53:25 -0000 1.4
@@ -1 +1 @@
-45992df3b24f23e051ff3c647dd24bdf meld3-0.6.3.tar.gz
+0fcb7496e20068155f6dd7d227edb76e meld3-0.6.4.tar.gz
More information about the fedora-extras-commits
mailing list