def _segmentation_guts(root, file_paths, max_partition_size):
<EOL>if not root.endswith(os.path.sep):<EOL><INDENT>root += os.path.sep<EOL><DEDENT>if not os.path.isdir(root):<EOL><INDENT>raise TarBadRootError(root=root)<EOL><DEDENT>bogus_tar = None<EOL>try:<EOL><INDENT>bogus_tar = tarfile.TarFile(os.devnull, '<STR_LIT:w>', dereference=False)<EOL>partition_number = <NUM_LIT:0><EOL>partition_bytes = <NUM_LIT:0><EOL>partition_members = <NUM_LIT:0><EOL>partition = TarPartition(partition_number)<EOL>for file_path in file_paths:<EOL><INDENT>if not file_path.startswith(root):<EOL><INDENT>raise TarBadPathError(root=root, offensive_path=file_path)<EOL><DEDENT>try:<EOL><INDENT>et_info = ExtendedTarInfo(<EOL>tarinfo=bogus_tar.gettarinfo(<EOL>file_path, arcname=file_path[len(root):]),<EOL>submitted_path=file_path)<EOL><DEDENT>except EnvironmentError as e:<EOL><INDENT>if (e.errno == errno.ENOENT and<EOL>e.filename == file_path):<EOL><INDENT>logger.debug(<EOL>msg='<STR_LIT>',<EOL>detail='<STR_LIT>'.format(et_info.submitted_path))<EOL>continue<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>if et_info.tarinfo.size > max_partition_size:<EOL><INDENT>raise TarMemberTooBigError(<EOL>et_info.tarinfo.name, max_partition_size,<EOL>et_info.tarinfo.size)<EOL><DEDENT>if (partition_bytes + et_info.tarinfo.size >= max_partition_size<EOL>or partition_members >= PARTITION_MAX_MEMBERS):<EOL><INDENT>yield partition<EOL>partition_number += <NUM_LIT:1><EOL>partition_bytes = et_info.tarinfo.size<EOL>partition_members = <NUM_LIT:1><EOL>partition = TarPartition(<EOL>partition_number, [et_info])<EOL><DEDENT>else:<EOL><INDENT>partition_bytes += et_info.tarinfo.size<EOL>partition_members += <NUM_LIT:1><EOL>partition.append(et_info)<EOL>assert partition_bytes < max_partition_size<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>if bogus_tar is not None:<EOL><INDENT>bogus_tar.close()<EOL><DEDENT><DEDENT>if partition:<EOL><INDENT>yield partition<EOL><DEDENT>
Segment a series of file paths into TarPartition values

    These TarPartitions are disjoint and roughly below the prescribed
    size.