Globals/__init__.py

changeset 4686
5f8a5c568230
parent 4631
5c1a96925da4
child 4695
9dc08852de25
--- a/Globals/__init__.py	Sun Jan 17 15:15:15 2016 +0100
+++ b/Globals/__init__.py	Sat Jan 23 16:21:23 2016 +0100
@@ -248,6 +248,35 @@
 
 
 ###############################################################################
+## functions for extended string handling
+###############################################################################
+
+
+def strGroup(txt, sep, groupLen=4):
+    """
+    Module function to group a string into sub-strings separated by a
+    separator.
+    
+    @param txt text to be grouped
+    @type str
+    @param sep separator string
+    @type str
+    @param groupLen length of each group
+    @type int
+    @return result string
+    @rtype str
+    """
+    l=[]
+    
+    while len(txt) // groupLen != 0:
+        l.insert(0, txt[-groupLen:])
+        txt = txt[:-groupLen]
+    if len(txt) > 0:
+        l.insert(0, txt)
+    return sep.join(l)
+
+
+###############################################################################
 ## functions for converting QSetting return types to valid types
 ###############################################################################
 

eric ide

mercurial