Return a string representation for this object.
(self)
| 269 | return result |
| 270 | |
| 271 | def __repr__(self): |
| 272 | """ |
| 273 | Return a string representation for this object. |
| 274 | """ |
| 275 | klass_name = type(self).__name__ |
| 276 | display_width = OPTIONS["display_width"] |
| 277 | offset = len(klass_name) + 2 |
| 278 | |
| 279 | if len(self) <= ITEMS_IN_REPR_MAX_ELSE_ELLIPSIS: |
| 280 | datastr = format_times( |
| 281 | self.values, display_width, offset=offset, first_row_offset=0 |
| 282 | ) |
| 283 | else: |
| 284 | front_str = format_times( |
| 285 | self.values[:REPR_ELLIPSIS_SHOW_ITEMS_FRONT_END], |
| 286 | display_width, |
| 287 | offset=offset, |
| 288 | first_row_offset=0, |
| 289 | last_row_end=",", |
| 290 | ) |
| 291 | end_str = format_times( |
| 292 | self.values[-REPR_ELLIPSIS_SHOW_ITEMS_FRONT_END:], |
| 293 | display_width, |
| 294 | offset=offset, |
| 295 | first_row_offset=offset, |
| 296 | ) |
| 297 | datastr = "\n".join([front_str, f"{' ' * offset}...", end_str]) |
| 298 | |
| 299 | attrs_str = format_attrs(self) |
| 300 | # oneliner only if smaller than display_width |
| 301 | full_repr_str = f"{klass_name}([{datastr}], {attrs_str})" |
| 302 | if len(full_repr_str) > display_width: |
| 303 | # if attrs_str too long, one per line |
| 304 | if len(attrs_str) >= display_width - offset: |
| 305 | attrs_str = attrs_str.replace(",", f",\n{' ' * (offset - 2)}") |
| 306 | full_repr_str = ( |
| 307 | f"{klass_name}([{datastr}],\n{' ' * (offset - 1)}{attrs_str})" |
| 308 | ) |
| 309 | |
| 310 | return full_repr_str |
| 311 | |
| 312 | def _partial_date_slice(self, resolution, parsed): |
| 313 | """Adapted from |
nothing calls this directly
no test coverage detected