utils.py: add class IdentStr for incrementing strings
authorrgbecker
Thu, 26 May 2011 14:08:20 +0000
changeset 3517 d49ec5554d81
parent 3515 1a478386c350
child 3518 3f201e3d0432
utils.py: add class IdentStr for incrementing strings
src/reportlab/lib/utils.py
--- a/src/reportlab/lib/utils.py	Fri May 20 14:29:09 2011 +0000
+++ b/src/reportlab/lib/utils.py	Thu May 26 14:08:20 2011 +0000
@@ -1167,4 +1167,17 @@
     data = data.replace(">", ">")
     data = data.replace("<", "<")
     return data
-    
+
+class IdentStr(str):
+    '''useful for identifying things that get split'''
+    def __new__(cls,value):
+        if isinstance(value,IdentStr):
+            inc = value.__inc
+            value = value[:-(2+len(str(inc)))]
+            inc += 1
+        else:
+            inc = 0
+        value += '[%d]' % inc
+        self = str.__new__(cls,value)
+        self.__inc = inc
+        return self