| 440 | |
| 441 | |
| 442 | class Breakable(Printable): |
| 443 | |
| 444 | def __init__(self, seq, width, pretty): |
| 445 | self.obj = seq |
| 446 | self.width = width |
| 447 | self.pretty = pretty |
| 448 | self.indentation = pretty.indentation |
| 449 | self.group = pretty.group_stack[-1] |
| 450 | self.group.breakables.append(self) |
| 451 | |
| 452 | def output(self, stream, output_width): |
| 453 | self.group.breakables.popleft() |
| 454 | if self.group.want_break: |
| 455 | stream.write(self.pretty.newline) |
| 456 | stream.write(' ' * self.indentation) |
| 457 | return self.indentation |
| 458 | if not self.group.breakables: |
| 459 | self.pretty.group_queue.remove(self.group) |
| 460 | stream.write(self.obj) |
| 461 | return output_width + self.width |
| 462 | |
| 463 | |
| 464 | class Group(Printable): |