ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/cal_module.py
(Generate patch)
# Line 153 | Line 153
153              roi.value -= roi.value[0]
154      return
155      """End of zerovalue()"""
156 +    
157 +
158 + def flattenlist(lst, ltypes=(list, tuple)):
159 +    """
160 +    Flatten nested lists into one list.
161 +
162 +    :param lst: Non-list, list, or list of lists!
163 +    :returns: flat list
164 +    """
165 +    lst = [lst]
166 +    ltype = type(lst)
167 +    lst = list(lst)
168 +    i = 0
169 +    while (len(lst) > i):
170 +        while isinstance(lst[i], ltypes):
171 +            if not lst[i]:
172 +                lst.pop(i)
173 +                i -= 1
174 +                break
175 +            else:
176 +                lst[i:i + 1] = lst[i]
177 +        i += 1
178 +    return ltype(lst)
179 +    """End of flattenlist()"""
180  
181   ################################# End of module #################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines