logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

r30208 - in lxml/branch/capi: doc src/lxml: msg#00049

Subject: r30208 - in lxml/branch/capi: doc src/lxml
Author: scoder
Date: Wed Jul 19 09:33:23 2006
New Revision: 30208

Modified:
   lxml/branch/capi/doc/objectify.txt
   lxml/branch/capi/src/lxml/objectify.pyx
   lxml/branch/capi/src/lxml/python.pxd
Log:
made '%' work for strings

Modified: lxml/branch/capi/doc/objectify.txt
==============================================================================
--- lxml/branch/capi/doc/objectify.txt  (original)
+++ lxml/branch/capi/doc/objectify.txt  Wed Jul 19 09:33:23 2006
@@ -113,6 +113,9 @@
     >>> el.text = "5"
     >>> print el + "10"
     510
+    >>> el.text = "%s - %s"
+    >>> print el % (1234, 12345)
+    1234 - 12345
 
 
 Resetting the API

Modified: lxml/branch/capi/src/lxml/objectify.pyx
==============================================================================
--- lxml/branch/capi/src/lxml/objectify.pyx     (original)
+++ lxml/branch/capi/src/lxml/objectify.pyx     Wed Jul 19 09:33:23 2006
@@ -284,6 +284,16 @@
         else:
             raise TypeError, "invalid types for * operator"
 
+    def __mod__(self, other):
+        if python.PyTuple_Check(other):
+            l = []
+            for item in other:
+                python.PyList_Append(l, _strValueOf(item))
+            other = tuple(l)
+        else:
+            other = _strValueOf(other)
+        return _strValueOf(self) % other
+
     def __getitem__(self, index):
         return textOf(self._c_node)[index]
 

Modified: lxml/branch/capi/src/lxml/python.pxd
==============================================================================
--- lxml/branch/capi/src/lxml/python.pxd        (original)
+++ lxml/branch/capi/src/lxml/python.pxd        Wed Jul 19 09:33:23 2006
@@ -50,6 +50,7 @@
     cdef object PyTuple_GET_ITEM(object o, Py_ssize_t pos)
 
     cdef int PyDict_Check(object instance)
+    cdef int PyTuple_Check(object instance)
     cdef int PyNumber_Check(object instance)
     cdef int PyBool_Check(object instance)
     cdef int PySequence_Check(object instance)


<Prev in Thread] Current Thread [Next in Thread>