module_types
pretty_print.html
¶
type_name | pretty_print.html | The registered name for this item type. | |||||||||
documentation | -- n/a -- |
Documentation for the item. | |||||||||
authors |
|
Information about authorship for the item. | |||||||||
context |
|
Generic properties of this item (description, tags, labels, references, ...). | |||||||||
python_class |
|
The python class that implements this module type. | |||||||||
module_src | class PrettyPrintWebModule(PrettyPrintModule): _module_type_name = "pretty_print.html" def pretty_print__table__as__html( self, value: Value, render_config: Dict[str, Any] ): max_rows = render_config.get( "max_no_rows", DEFAULT_PRETTY_PRINT_CONFIG["max_no_rows"] ) max_row_height = render_config.get( "max_row_height", DEFAULT_PRETTY_PRINT_CONFIG["max_row_height"] ) max_cell_length = render_config.get( "max_cell_length", DEFAULT_PRETTY_PRINT_CONFIG["max_cell_length"] ) half_lines: Union[None, int] = None if max_rows: half_lines = int(max_rows / 2) atw = ArrowTabularWrap(value.data.arrow_table) result = atw.as_html( rows_head=half_lines, rows_tail=half_lines, max_row_height=max_row_height, max_cell_length=max_cell_length, ) return result | The source code of the process method of the module. |
render.core_types.for.web
¶
type_name | render.core_types.for.web | The registered name for this item type. | |||||||||
documentation | -- n/a -- |
Documentation for the item. | |||||||||
authors |
|
Information about authorship for the item. | |||||||||
context |
|
Generic properties of this item (description, tags, labels, references, ...). | |||||||||
python_class |
|
The python class that implements this module type. | |||||||||
module_src | class RenderCoreTypeModuleWeb(RenderValueModule): _module_type_name = "render.core_types.for.web" def render__dict__as__html(self, value: Value, render_config: Mapping[str, Any]): render_scene = render_config.get("scene_name", "data") # input_number_of_rows = render_config.get("number_of_rows", 20) # input_row_offset = render_config.get("row_offset", 0) as_table = render_config.get("as_table", True) dict_model: KiaraDict = value.data if render_scene == "data": to_render = dict_model.dict_data elif render_scene == "schema": to_render = dict_model.data_schema else: raise KiaraProcessingException( f"Invalid value '{render_scene}' argument 'scene_name': only 'data' and 'schema' are allowed" ) from json2html import json2html if as_table: if not to_render: pretty = "-- empty dict --" else: pretty = json2html.convert( json=to_render, table_attributes=f'id="dict-preview-{ value.value_id }" class=""', ) else: json_string = orjson_dumps( dict_model.dict_data, option=orjson.OPT_NON_STR_KEYS | orjson.OPT_INDENT_2, ) pretty = highlight(json_string, JsonLexer(), HtmlFormatter()) related_scenes = { "data": RenderScene.construct( title="data", disabled=render_scene == "data", description="Render the data of the dict.", manifest_hash=self.manifest.manifest_hash, render_config={"scene_name": "data"}, ), "schema": RenderScene.construct( title="schema", disabled=render_scene == "schema", description="Show the (json) schema of the dict value.", manifest_hash=self.manifest.manifest_hash, render_config={"scene_name": "schema"}, ), } return RenderValueResult( value_id=value.value_id, render_config=render_config, render_manifest=self.manifest.manifest_hash, rendered=pretty, related_scenes=related_scenes, ) | The source code of the process method of the module. |
render.included_types.for.web
¶
type_name | render.included_types.for.web | The registered name for this item type. | |||||||||
documentation | -- n/a -- |
Documentation for the item. | |||||||||
authors |
|
Information about authorship for the item. | |||||||||
context |
|
Generic properties of this item (description, tags, labels, references, ...). | |||||||||
python_class |
|
The python class that implements this module type. | |||||||||
module_src | class RenderCoreTypeModuleWeb(RenderValueModule):
_module_type_name = "render.included_types.for.web"
def render__none__as__html(self, value: Value, render_config: Mapping[str, Any]):
return RenderValueResult(
value_id=value.value_id,
render_config=render_config,
render_manifest=self.manifest.manifest_hash,
rendered=" -- value empty -- ",
related_scenes={},
)
def render__file_bundle__as__html(
self, value: Value, render_config: Mapping[str, Any]
):
import humanfriendly
# render_scene = render_config.get("scene_name", "data")
file_bundle: KiaraFileBundle = value.data
# to_render = file_bundle.dict()
doc = Airium()
with doc.table():
with doc.tr():
with doc.th():
doc("included_files")
with doc.th():
doc("metadata")
with doc.tr():
with doc.td():
with doc.table():
for file_name, incl_file in file_bundle.included_files.items():
with doc.tr():
with doc.td():
doc(file_name)
with doc.td():
file_size = humanfriendly.format_size(
incl_file.size
)
doc(file_size)
with doc.td():
with doc.table():
with doc.tr():
with doc.td():
doc("bundle name")
with doc.td():
doc(file_bundle.bundle_name)
with doc.tr():
with doc.td():
doc("bundle size")
with doc.td():
bundle_size = humanfriendly.format_size(
file_bundle.size
)
doc(bundle_size)
pretty = str(doc)
return RenderValueResult(
value_id=value.value_id,
render_config=render_config,
render_manifest=self.manifest.manifest_hash,
rendered=pretty,
related_scenes={},
)
def render__file__as__html(self, value: Value, render_config: Mapping[str, Any]):
# render_scene = render_config.get("scene_name", "data")
file: KiaraFile = value.data
text = file.read_text(max_lines=20)
text = f"{text}\n\n... (truncated)"
text = text.replace("\n", "") pretty = text return RenderValueResult( value_id=value.value_id, render_config=render_config, render_manifest=self.manifest.manifest_hash, rendered=pretty, related_scenes={}, ) |
The source code of the process method of the module. |
render.markdown.to.html
¶
type_name | render.markdown.to.html | The registered name for this item type. | |||||||||
documentation | -- n/a -- |
Documentation for the item. | |||||||||
authors |
|
Information about authorship for the item. | |||||||||
context |
|
Generic properties of this item (description, tags, labels, references, ...). | |||||||||
python_class |
|
The python class that implements this module type. | |||||||||
module_src | class RenderMarkdown(KiaraModule): _module_type_name = "render.markdown.to.html" def create_inputs_schema( self, ) -> ValueMapSchema: return {"markdown": {"type": "string", "doc": "The markdown string"}} def create_outputs_schema( self, ) -> ValueMapSchema: return {"html": {"type": "html", "doc": "The rendered html"}} def process(self, inputs: ValueMap, outputs: ValueMap): import markdown markdown_string = inputs.get_value_data("markdown") html = markdown.markdown(markdown_string) outputs.set_value("html", html) | The source code of the process method of the module. |