appy.pod: variable named 'loop' is now available in the POD context of any section within a 'for' statement, with attributes like loop.[iterVariableName].length (=total number of looped elements) and loop.[iterVariableName].nb (=index of currently looped element).

This commit is contained in:
Gaetan Delannay 2012-03-16 14:59:59 +01:00
parent 0dd8b72dca
commit cbb8d5cd12
3 changed files with 58 additions and 1 deletions

View file

@ -127,6 +127,24 @@ def copyData(data, target, targetMethod, type='string', encoding=None,
dump(encodeData(data.data, encoding))
data = data.next
# ------------------------------------------------------------------------------
def splitList(l, sub):
'''Returns a list that was build from list p_l whose elements were
re-grouped into sub-lists of p_sub elements.
For example, if l = [1,2,3,4,5] and sub = 3, the method returns
[ [1,2,3], [4,5] ].'''
res = []
i = -1
for elem in l:
i += 1
if (i % sub) == 0:
# A new sub-list must be created
res.append([elem])
else:
res[-1].append(elem)
return res
# ------------------------------------------------------------------------------
class Traceback:
'''Dumps the last traceback into a string.'''