Skip to content

Commit

Permalink
Merge pull request Ericsson#3760 from vodorok/chunk_fix
Browse files Browse the repository at this point in the history
[fix] Fix chunks function not working on certain iterables
  • Loading branch information
bruntib authored Oct 15, 2022
2 parents fc24fa7 + 7136feb commit 96db6ec
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions codechecker_common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def chunks(iterator, n):
Yield the next chunk if an iterable object. A chunk consists of maximum n
elements.
"""
iterator = iter(iterator)
for first in iterator:
rest_of_chunk = itertools.islice(iterator, 0, n - 1)
yield itertools.chain([first], rest_of_chunk)

0 comments on commit 96db6ec

Please sign in to comment.