| 1579 | |
| 1580 | |
| 1581 | class _ScriptProfileColumn: |
| 1582 | def __init__(self, header: str, alignment: int = 4, offset: int = 0): |
| 1583 | self.header = header |
| 1584 | self.alignment = alignment |
| 1585 | self.offset = offset |
| 1586 | self.rows: Dict[int, Any] = {} |
| 1587 | |
| 1588 | def add_row(self, lineno: int, value: Any): |
| 1589 | self.rows[lineno] = value |
| 1590 | |
| 1591 | def materialize(self): |
| 1592 | max_length = len(self.header) |
| 1593 | rows: List[Tuple[int, str]] = [] |
| 1594 | for key, value in self.rows.items(): |
| 1595 | cell = str(value) |
| 1596 | rows.append((key, cell)) |
| 1597 | max_length = max(len(cell), max_length) |
| 1598 | |
| 1599 | if self.alignment > 0: |
| 1600 | padding = max_length + self.alignment |
| 1601 | padding -= padding % self.alignment |
| 1602 | else: |
| 1603 | padding = 0 |
| 1604 | |
| 1605 | rows = [(key, pad(cell, padding, self.offset)) for key, cell in rows] |
| 1606 | return pad(self.header, padding, self.offset), rows |
| 1607 | |
| 1608 | |
| 1609 | class _ScriptProfileTable: |
no outgoing calls
no test coverage detected
searching dependent graphs…