VulpesOS/gaia/bin/chunk
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

29 lines
820 B
Python
Executable file

#! /usr/bin/env python
import argparse
import math
parser = argparse.ArgumentParser(description='Chunk a list of files')
parser.add_argument('total_chunks', metavar='<total-chunks>', type=float,
help='total number of chunks')
parser.add_argument('this_chunk', metavar='<nth-chunk>', type=float,
help='Nth chunk to run')
parser.add_argument('files', metavar='files', type=str,
nargs='+', help='files to sort and chunk')
args = parser.parse_args()
def main(args):
if len(args.files) < args.total_chunks:
print(' '.join(args.files))
return
chunk_length = int(math.ceil(len(args.files) / args.total_chunks))
chunk = int((args.this_chunk - 1) * chunk_length)
print(' '.join(args.files[chunk:chunk + chunk_length]))
main(args)