def _shallow_split(filenames, size_per_shard, parsed_formats, sizes):
 roots = []
 inputs = []
 shard_size = 0
 for (i, size) in enumerate(sizes):
  shard_size += size
  inputs.append(_FileRange(filenames[i], None))
  if (shard_size >= size_per_shard):
   roots.append(FileFormatRoot(copy.deepcopy(parsed_formats), inputs))
   inputs = []
   shard_size = 0
 if inputs:
  roots.append(FileFormatRoot(copy.deepcopy(parsed_formats), inputs))
 return roots

def _shallow_split ( filenames , size_per_shard , parsed_formats , sizes ) : roots = [ ] inputs = [ ] shard_size = 0 for ( i , size ) in enumerate ( sizes ) : shard_size += size inputs . append ( _FileRange ( filenames [ i ] , None ) ) if ( shard_size >= size_per_shard ) : roots . append ( FileFormatRoot ( copy . deepcopy ( parsed_formats ) , inputs ) ) inputs = [ ] shard_size = 0 if inputs : roots . append ( FileFormatRoot ( copy . deepcopy ( parsed_formats ) , inputs ) ) return roots
split files into roots only based on top level file sizes .