def write(self, handle: TextIO, blank_lines: int = <NUM_LIT:1>) -> None:
if not isinstance(blank_lines, int) or blank_lines <= <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>writer = csv.writer(handle)<EOL>csv_width: int = max([len(self.all_sample_keys), <NUM_LIT:2>])<EOL>section_order = ['<STR_LIT>', '<STR_LIT>'] + self._sections + ['<STR_LIT>']<EOL>def pad_iterable(<EOL>iterable: Iterable, size: int = csv_width, padding: str = '<STR_LIT>'<EOL>) -> List[str]:<EOL><INDENT>return list(islice(chain(iterable, repeat(padding)), size))<EOL><DEDENT>def write_blank_lines(<EOL>writer: Any, n: int = blank_lines, width: int = csv_width<EOL>) -> None:<EOL><INDENT>for i in range(n):<EOL><INDENT>writer.writerow(pad_iterable([], width))<EOL><DEDENT><DEDENT>for title in section_order:<EOL><INDENT>writer.writerow(pad_iterable([f'<STR_LIT>'], csv_width))<EOL>section = getattr(self, title)<EOL>if title == '<STR_LIT>':<EOL><INDENT>for read in self.Reads:<EOL><INDENT>writer.writerow(pad_iterable([read], csv_width))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for key, value in section.items():<EOL><INDENT>writer.writerow(pad_iterable([key, value], csv_width))<EOL><DEDENT><DEDENT>write_blank_lines(writer)<EOL><DEDENT>writer.writerow(pad_iterable(['<STR_LIT>'], csv_width))<EOL>writer.writerow(pad_iterable(self.all_sample_keys, csv_width))<EOL>for sample in self.samples:<EOL><INDENT>line = [getattr(sample, key) for key in self.all_sample_keys]<EOL>writer.writerow(pad_iterable(line, csv_width))<EOL><DEDENT>
Write this :class:`SampleSheet` to a file-like object.

        Args:
            handle: Object to wrap by csv.writer.
            blank_lines: Number of blank lines to write between sections.