Skip to content

Report Writer

Reporting module for writing output to files, including HTML reports.

Classes:

Name Description
TextWriter

A class to handle recursive writing of nested data structures to text files.

HTMLWriter

A class to handle writing HTML content.

JSONWriter

A class to handle writing JSON content.

Writers

A dataclass to hold different types of writers for reporting.

ReportWriter

A class to handle reporting and writing output to files, including text, JSON, and HTML formats.

TextWriter

A class to handle recursive writing of nested data structures to text files.

Methods:

Name Description
write

Write the data to a plain text file with the given prefix and count.

write_recursive

Recursive function to write nested data structures to plain text files.

write_toplevel_dict

Write the top-level dictionary to a file.

write_values_is_dict

Write values of a dictionary to a file with indentation.

write_values_is_collection

Write values of a collection to a file with indentation.

write_not_toplevel_dict

Write the non-top-level dictionary to a file.

write_nested_dict

Write nested dictionaries to a file with indentation.

write_nested_collection

Write collections (lists, sets) to a file with indentation.

write(outputpath: Path, prefix: str, count: int | None, filename: str, data: Any) -> None staticmethod

Write the data to a plain text file with the given prefix and count.

write_recursive(f: TextIO, data: Any, indent_level: int = 0) -> None staticmethod

Recursive function to write nested data structures to plain text files.

write_toplevel_dict(f: TextIO, data: dict, indent: str, indent_level: int = 0) -> None staticmethod

Write the top-level dictionary to a file.

write_values_is_dict(f: TextIO, data: dict, indent: str, indent_level: int = 0) -> None staticmethod

Write values of a dictionary to a file with indentation.

write_values_is_collection(f: TextIO, values: Any, indent: str) -> None staticmethod

Write values of a collection to a file with indentation.

write_not_toplevel_dict(f: TextIO, data: Any, indent: str, indent_level: int = 0) -> None staticmethod

Write the non-top-level dictionary to a file.

write_nested_dict(f: TextIO, data: dict, indent: str, indent_level: int = 0) -> None staticmethod

Write nested dictionaries to a file with indentation.

write_nested_collection(f: TextIO, data: Any, indent: str, indent_level: int = 0) -> None staticmethod

Write collections (lists, sets) to a file with indentation.

HTMLWriter

A class to handle writing HTML content.

Methods:

Name Description
write

Write the data to an HTML file with the given prefix and count.

write_html_recursive

Recursive helper to write nested data structures into HTML format.

write_collection_html

Write collections (lists, sets) to HTML format.

write_dict_html

Write a dictionary to HTML format.

write(outputpath: Path, prefix: str, count: int | None, filename: str, data: Any) -> None staticmethod

Write the data to an HTML file with the given prefix and count.

Parameters:

Name Type Description Default
outputpath Path

The path where the HTML file will be written.

required
prefix str

The prefix for the HTML title and header.

required
count int | None

The count of items, if applicable.

required
filename str

The name of the file being processed.

required
data Any

The data to be written to the HTML file.

required

write_html_recursive(f: TextIO, data: Any) -> None staticmethod

Recursive helper to write nested data structures into HTML format.

Uses

for dicts,
    for lists/sets, and for simple values.

write_collection_html(f: TextIO, data: Any) -> None staticmethod

Write collections (lists, sets) to HTML format.

Uses

    for ordered lists and
  1. for items.

write_dict_html(f: TextIO, data: dict) -> None staticmethod

Write a dictionary to HTML format.

Uses

for definition lists,
for terms, and
for definitions.

JSONWriter

A class to handle writing JSON content.

Methods:

Name Description
write

Write the data to a JSON file.

write(outputpath: Path, prefix: str, count: int | None, filename: str, data: Any) -> None staticmethod

Write the data to a JSON file.

Writers(text: TextWriter = TextWriter(), html: HTMLWriter = HTMLWriter(), json: JSONWriter = JSONWriter()) dataclass

A dataclass to hold different types of writers for reporting.

ReportWriter(prefix: str, data: Any, subdir: str, writer: Writers = Writers()) dataclass

A class to handle reporting and writing output to files, including text, JSON, and HTML formats.

Methods:

Name Description
configure

Configure the ReportWriter class with necessary settings.

write

Write the report to a file in the configured format (TXT, JSON, or HTML).

get_output_path

Get the output path for the report file.

configure(args: Args, analyzer_dirs: LogseqAnalyzerDirs) -> None classmethod

Configure the ReportWriter class with necessary settings.

Parameters:

Name Type Description Default
args Args

The command-line arguments.

required
analyzer_dirs LogseqAnalyzerDirs

The directories used by the Logseq Analyzer.

required

write() -> None

Write the report to a file in the configured format (TXT, JSON, or HTML).

get_output_path(filename: str) -> Path

Get the output path for the report file.

Parameters:

Name Type Description Default
filename str

The name of the file to be created.

required

Returns:

Name Type Description
Path Path

The output path for the report file.