Clash Data Export#
Overview#
File Name: clash_detect_export.py
This file provides functionality to export data in JSON and HTML formats. It includes the definition of export column properties and methods to convert data into specified formats.
ExportColumnDef Class#
- class ExportColumnDef#
A class for defining export column properties. This class encapsulates the properties of a column definition used for exporting data, including the order of the column, its name, and its text alignment.
Constructor#
- __init__(order: int, name: str, alignment: bool = False) None
Initializes an instance of the ExportColumnDef class.
- Parameters:
order (int) – The order of the column in the export.
name (str) – The name of the column.
alignment (bool, optional) – The alignment of the text in the column; False for left alignment, True for right alignment.
- Default alignment:
False
Properties#
- order int #
Gets the order of the column.
- Returns:
The order of the column.
- Return type:
int
- name str #
Gets the name of the column.
- Returns:
The name of the column.
- Return type:
str
- alignment bool #
Gets the alignment of the column. False for left alignment, True for right alignment.
- Returns:
The alignment of the column.
- Return type:
bool
Functions#
export_to_json#
- export_to_json(
- column_defs: Sequence[ExportColumnDef],
- rows: Sequence[Sequence[str]],
Convert the given data to a JSON format.
- Parameters:
column_defs (Sequence[ExportColumnDef]) – List of column definitions.
rows (Sequence[Sequence[str]]) – Data rows to be exported.
- Returns:
JSON representation of the data encoded in UTF-8.
- Return type:
bytes
export_to_html#
- export_to_html(
- title: str,
- subtitle: str,
- column_defs: Sequence[ExportColumnDef],
- rows: Sequence[Sequence[str]],
Convert the given data to an HTML format.
- Parameters:
title (str) – Title of the HTML document.
subtitle (str) – Subtitle of the HTML document.
column_defs (Sequence[ExportColumnDef]) – List of column definitions.
rows (Sequence[Sequence[str]]) – Data rows to be exported.
- Returns:
HTML representation of the data encoded in UTF-8.
- Return type:
bytes