MCPcopy Create free account
hub / github.com/datapane/datapane / MarkdownFormatter

Class MarkdownFormatter

python-client/src/datapane/client/utils.py:127–146  ·  view source on GitHub ↗

Support {:l} and {:cmd} format fields

Source from the content-addressed store, hash-verified

125
126
127class MarkdownFormatter(string.Formatter):
128 """Support {:l} and {:cmd} format fields"""
129
130 in_jupyter: bool
131
132 def __init__(self, in_jupyter: bool):
133 self.in_jupyter = in_jupyter
134 super().__init__()
135
136 def format_field(self, value: t.Any, format_spec: str) -> t.Any:
137 if format_spec.endswith("l"):
138 if self.in_jupyter:
139 value = f"<a href='{value}' target='_blank'>here</a>"
140 else:
141 value = f"at {value}"
142 format_spec = format_spec[:-1]
143 elif format_spec.endswith("cmd"):
144 value = f"!{value}" if self.in_jupyter else value
145 format_spec = format_spec[:-3]
146 return super().format_field(value, format_spec)
147
148
149def display_msg(text: str, **params: str):

Callers 1

display_msgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected