Outputs the provided data using the transformations and output format specified for this CLI endpoint
(self, data, context)
| 550 | self.api.cli.commands[route.get("name", self.interface.spec.__name__)] = self |
| 551 | |
| 552 | def output(self, data, context): |
| 553 | """Outputs the provided data using the transformations and output format specified for this CLI endpoint""" |
| 554 | if self.transform: |
| 555 | if hasattr(self.transform, "context"): |
| 556 | self.transform.context = context |
| 557 | data = self.transform(data) |
| 558 | if hasattr(data, "read"): |
| 559 | data = data.read().decode("utf8") |
| 560 | if data is not None: |
| 561 | data = self.outputs(data) |
| 562 | if data: |
| 563 | sys.stdout.buffer.write(data) |
| 564 | if not data.endswith(b"\n"): |
| 565 | sys.stdout.buffer.write(b"\n") |
| 566 | return data |
| 567 | |
| 568 | def __str__(self): |
| 569 | return self.parser.description or "" |