REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.47 KB
Close
//proc/self/root/opt/cloudlinux/venv/lib/python3.11/site-packages/pylint/pyreverse/mermaidjs_printer.py
Text
Base64
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html # For details: https://github.com/PyCQA/pylint/blob/main/LICENSE # Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt """Class to generate files in mermaidjs format.""" from __future__ import annotations from pylint.pyreverse.printer import EdgeType, NodeProperties, NodeType, Printer from pylint.pyreverse.utils import get_annotation_label class MermaidJSPrinter(Printer): """Printer for MermaidJS diagrams.""" DEFAULT_COLOR = "black" NODES: dict[NodeType, str] = { NodeType.CLASS: "class", NodeType.INTERFACE: "class", NodeType.PACKAGE: "class", } ARROWS: dict[EdgeType, str] = { EdgeType.INHERITS: "--|>", EdgeType.IMPLEMENTS: "..|>", EdgeType.ASSOCIATION: "--*", EdgeType.AGGREGATION: "--o", EdgeType.USES: "-->", } def _open_graph(self) -> None: """Emit the header lines.""" self.emit("classDiagram") self._inc_indent() def emit_node( self, name: str, type_: NodeType, properties: NodeProperties | None = None, ) -> None: """Create a new node. Nodes can be classes, packages, participants etc. """ # pylint: disable=duplicate-code if properties is None: properties = NodeProperties(label=name) stereotype = "~~Interface~~" if type_ is NodeType.INTERFACE else "" nodetype = self.NODES[type_] body = [] if properties.attrs: body.extend(properties.attrs) if properties.methods: for func in properties.methods: args = self._get_method_arguments(func) line = f"{func.name}({', '.join(args)})" line += "*" if func.is_abstract() else "" if func.returns: line += f" {get_annotation_label(func.returns)}" body.append(line) name = name.split(".")[-1] self.emit(f"{nodetype} {name}{stereotype} {{") self._inc_indent() for line in body: self.emit(line) self._dec_indent() self.emit("}") def emit_edge( self, from_node: str, to_node: str, type_: EdgeType, label: str | None = None, ) -> None: """Create an edge from one node to another to display relationships.""" from_node = from_node.split(".")[-1] to_node = to_node.split(".")[-1] edge = f"{from_node} {self.ARROWS[type_]} {to_node}" if label: edge += f" : {label}" self.emit(edge) def _close_graph(self) -> None: """Emit the lines needed to properly close the graph.""" self._dec_indent() class HTMLMermaidJSPrinter(MermaidJSPrinter): """Printer for MermaidJS diagrams wrapped in a html boilerplate.""" HTML_OPEN_BOILERPLATE = """<html> <body> <script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script> <div class="mermaid"> """ HTML_CLOSE_BOILERPLATE = """ </div> </body> </html> """ GRAPH_INDENT_LEVEL = 4 def _open_graph(self) -> None: self.emit(self.HTML_OPEN_BOILERPLATE) for _ in range(self.GRAPH_INDENT_LEVEL): self._inc_indent() super()._open_graph() def _close_graph(self) -> None: for _ in range(self.GRAPH_INDENT_LEVEL): self._dec_indent() self.emit(self.HTML_CLOSE_BOILERPLATE)
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 13
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__pycache__
DIR
-
drwxr-xr-x
2026-02-05 08:01:15
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
diadefslib.py
8.50 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
diagrams.py
10.62 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
dot_printer.py
6.33 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
inspector.py
14.72 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
main.py
8.76 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
mermaidjs_printer.py
3.47 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
plantuml_printer.py
3.56 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
printer.py
3.65 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
printer_factory.py
900 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
utils.py
8.13 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
vcg_printer.py
8.67 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
writer.py
6.09 KB
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
__init__.py
274 B
lrw-r--r--
2026-01-20 13:01:48
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).