Summary for __repr__ - use ``X.attrs[key]`` for full value.
(key, value, col_width=None)
| 362 | |
| 363 | |
| 364 | def summarize_attr(key, value, col_width=None): |
| 365 | """Summary for __repr__ - use ``X.attrs[key]`` for full value.""" |
| 366 | # Indent key and add ':', then right-pad if col_width is not None |
| 367 | k_str = f" {key}:" |
| 368 | if col_width is not None: |
| 369 | k_str = pretty_print(k_str, col_width) |
| 370 | # Replace tabs and newlines, so we print on one line in known width |
| 371 | v_str = str(value).replace("\t", "\\t").replace("\n", "\\n") |
| 372 | # Finally, truncate to the desired display width |
| 373 | return maybe_truncate(f"{k_str} {v_str}", OPTIONS["display_width"]) |
| 374 | |
| 375 | |
| 376 | EMPTY_REPR = " *empty*" |
no test coverage detected
searching dependent graphs…