MCPcopy Index your code
hub / github.com/hugapi/hug / output

Method output

hug/interface.py:552–566  ·  view source on GitHub ↗

Outputs the provided data using the transformations and output format specified for this CLI endpoint

(self, data, context)

Source from the content-addressed store, hash-verified

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 ""

Callers 2

__call__Method · 0.95
test_outputMethod · 0.45

Calls 2

transformMethod · 0.80
outputsMethod · 0.45

Tested by 1

test_outputMethod · 0.36