(self, indent: int)
| 275 | self.write("</table>", indent) |
| 276 | |
| 277 | def _write_col_header(self, indent: int) -> None: |
| 278 | row: list[Hashable] |
| 279 | is_truncated_horizontally = self.fmt.is_truncated_horizontally |
| 280 | if isinstance(self.columns, MultiIndex): |
| 281 | template = 'colspan="{span:d}" halign="left"' |
| 282 | |
| 283 | sentinel: lib.NoDefault | bool |
| 284 | if self.fmt.sparsify: |
| 285 | # GH3547 |
| 286 | sentinel = lib.no_default |
| 287 | else: |
| 288 | sentinel = False |
| 289 | levels = self.columns._format_multi(sparsify=sentinel, include_names=False) |
| 290 | level_lengths = get_level_lengths(levels, sentinel) |
| 291 | inner_lvl = len(level_lengths) - 1 |
| 292 | for lnum, (records, values) in enumerate( |
| 293 | zip(level_lengths, levels, strict=True) |
| 294 | ): |
| 295 | if is_truncated_horizontally: |
| 296 | # modify the header lines |
| 297 | ins_col = self.fmt.tr_col_num |
| 298 | if self.fmt.sparsify: |
| 299 | recs_new = {} |
| 300 | # Increment tags after ... col. |
| 301 | for tag, span in list(records.items()): |
| 302 | if tag >= ins_col: |
| 303 | recs_new[tag + 1] = span |
| 304 | elif tag + span > ins_col: |
| 305 | recs_new[tag] = span + 1 |
| 306 | if lnum == inner_lvl: |
| 307 | values = ( |
| 308 | *values[:ins_col], |
| 309 | "...", |
| 310 | *values[ins_col:], |
| 311 | ) |
| 312 | else: |
| 313 | # sparse col headers do not receive a ... |
| 314 | values = ( |
| 315 | *values[:ins_col], |
| 316 | values[ins_col - 1], |
| 317 | *values[ins_col:], |
| 318 | ) |
| 319 | else: |
| 320 | recs_new[tag] = span |
| 321 | # if ins_col lies between tags, all col headers |
| 322 | # get ... |
| 323 | if tag + span == ins_col: |
| 324 | recs_new[ins_col] = 1 |
| 325 | values = (*values[:ins_col], "...", *values[ins_col:]) |
| 326 | records = recs_new |
| 327 | inner_lvl = len(level_lengths) - 1 |
| 328 | if lnum == inner_lvl: |
| 329 | records[ins_col] = 1 |
| 330 | else: |
| 331 | recs_new = {} |
| 332 | for tag, span in list(records.items()): |
| 333 | if tag >= ins_col: |
| 334 | recs_new[tag + 1] = span |
no test coverage detected