summaryrefslogtreecommitdiff
path: root/morphlib/util.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-11-22 15:06:13 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-11-22 15:06:13 +0000
commitb2b618f71d63290efbc849650459ce6cd467621d (patch)
treeda35dfd0f45e427622ca2a51045b7d2a3122bda4 /morphlib/util.py
parent0b3ec68ce46f638e79e52f9f97f26727d9c4daa1 (diff)
parent53d53ef939ee66de9b6dfbf5d2fe215fc7723400 (diff)
downloadmorph-b2b618f71d63290efbc849650459ce6cd467621d.tar.gz
Merge remote-tracking branch 'origin/baserock/richardmaw/S9475/build-refactor-foundations-v2'
Diffstat (limited to 'morphlib/util.py')
-rw-r--r--morphlib/util.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/morphlib/util.py b/morphlib/util.py
index 04df0633..dd2d05e1 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -13,6 +13,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+import itertools
import os
import re
@@ -412,3 +413,12 @@ def get_host_architecture(): # pragma: no cover
def sanitize_environment(env):
for k in env:
env[k] = str(env[k])
+
+def iter_trickle(iterable, limit):
+ '''Split an iterable up into `limit` length chunks.'''
+ it = iter(iterable)
+ while True:
+ buf = list(itertools.islice(it, limit))
+ if len(buf) == 0:
+ break
+ yield buf