[rhmessaging-commits] rhmessaging commits: r4107 - mgmt/newdata/parsley/python/parsley.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Jul 13 13:50:12 EDT 2010


Author: eallen
Date: 2010-07-13 13:50:12 -0400 (Tue, 13 Jul 2010)
New Revision: 4107

Added:
   mgmt/newdata/parsley/python/parsley/stringex.py
Log:
Wrappers for python 2.5's partition and rpartition

Added: mgmt/newdata/parsley/python/parsley/stringex.py
===================================================================
--- mgmt/newdata/parsley/python/parsley/stringex.py	                        (rev 0)
+++ mgmt/newdata/parsley/python/parsley/stringex.py	2010-07-13 17:50:12 UTC (rev 4107)
@@ -0,0 +1,22 @@
+try:
+    from string import partition, rpartition
+    def partition(str, sep):
+        return str.partition(sep)
+
+    def rpartition(str, sep):
+        return str.rpartition(sep)
+
+except ImportError:
+    def partition(str, sep):
+        i = str.find(sep)
+        if i >= 0:
+            return (str[:i], sep, str[i+1:])
+        else:
+            return (str, "", "")
+
+    def rpartition(str, sep):
+        i = str.rfind(sep)
+        if i >= 0:
+            return (str[:i], sep, str[i+1:])
+        else:
+            return ("", "", str)



More information about the rhmessaging-commits mailing list