mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
make sure chunk size is at least 1
This commit is contained in:
parent
1c2a72743d
commit
c9b0bb0e54
1 changed files with 5 additions and 2 deletions
|
|
@ -143,14 +143,17 @@ def create_chunks(iterable, chunk_size=None):
|
|||
list<list>: Chunked items.
|
||||
"""
|
||||
chunks = []
|
||||
if not iterable:
|
||||
return chunks
|
||||
|
||||
tupled_iterable = tuple(iterable)
|
||||
if not tupled_iterable:
|
||||
return chunks
|
||||
iterable_size = len(tupled_iterable)
|
||||
if chunk_size is None:
|
||||
chunk_size = 200
|
||||
|
||||
if chunk_size < 1:
|
||||
chunk_size = 1
|
||||
|
||||
for idx in range(0, iterable_size, chunk_size):
|
||||
chunks.append(tupled_iterable[idx:idx + chunk_size])
|
||||
return chunks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue