Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/deploy-on-aws/scripts/lib/fix_icon_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import argparse
import defusedxml.ElementTree as ET
from xml.etree.ElementTree import Element, ElementTree

# Broken shape names → correct shape names
SHAPE_RENAMES: dict[str, str] = {
Expand Down Expand Up @@ -195,7 +196,7 @@ def _extract_color(value: str) -> str | None:
return None


def fix_icon_colors(tree: ET.ElementTree, verbose: bool = False) -> int:
def fix_icon_colors(tree: ElementTree, verbose: bool = False) -> int:
"""Fix icon fillColor, container tint/stroke, and broken shape names.

1. Rename broken resIcon shapes (e.g., iam → identity_and_access_management)
Expand All @@ -208,7 +209,7 @@ def fix_icon_colors(tree: ET.ElementTree, verbose: bool = False) -> int:
fixed = 0

# Build a map of cell ID → cell element
cells: dict[str, ET.Element] = {}
cells: dict[str, Element] = {}
for cell in root_elem.iter("mxCell"):
cid = cell.get("id")
if cid:
Expand Down
11 changes: 6 additions & 5 deletions plugins/deploy-on-aws/scripts/lib/fix_nesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import argparse
import defusedxml.ElementTree as ET
from xml.etree.ElementTree import Element, ElementTree


def get_style_dict(style_str: str) -> dict[str, str]:
Expand Down Expand Up @@ -54,7 +55,7 @@ def set_style_value(style_str: str, key: str, value: str) -> str:
return ";".join(parts) + ";"


def get_geometry(cell: ET.Element) -> tuple[float, float, float, float] | None:
def get_geometry(cell: Element) -> tuple[float, float, float, float] | None:
for geom in cell:
if geom.tag == "mxGeometry" and geom.get("as") == "geometry":
x = float(geom.get("x", "0"))
Expand All @@ -65,7 +66,7 @@ def get_geometry(cell: ET.Element) -> tuple[float, float, float, float] | None:
return None


def offset_geometry(cell: ET.Element, dx: float, dy: float) -> None:
def offset_geometry(cell: Element, dx: float, dy: float) -> None:
for geom in cell:
if geom.tag == "mxGeometry" and geom.get("as") == "geometry":
if geom.get("relative") == "1":
Expand All @@ -77,7 +78,7 @@ def offset_geometry(cell: ET.Element, dx: float, dy: float) -> None:
return


def is_region_container(cell: ET.Element) -> bool:
def is_region_container(cell: Element) -> bool:
style = cell.get("style", "")
style_dict = get_style_dict(style)
return (
Expand All @@ -86,10 +87,10 @@ def is_region_container(cell: ET.Element) -> bool:
)


def fix_nesting(tree: ET.ElementTree, verbose: bool = False) -> int:
def fix_nesting(tree: ElementTree, verbose: bool = False) -> int:
root_elem = tree.getroot()

cells: dict[str, ET.Element] = {}
cells: dict[str, Element] = {}
for cell in root_elem.iter("mxCell"):
cid = cell.get("id")
if cid:
Expand Down
17 changes: 9 additions & 8 deletions plugins/deploy-on-aws/scripts/lib/fix_step_badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import math
import re
import defusedxml.ElementTree as ET
from xml.etree.ElementTree import Element, ElementTree
from dataclasses import dataclass


Expand Down Expand Up @@ -88,7 +89,7 @@ def get_style_dict(style_str: str) -> dict[str, str]:
return result


def get_geometry(cell: ET.Element) -> Rect | None:
def get_geometry(cell: Element) -> Rect | None:
for geom in cell:
if geom.tag == "mxGeometry" and geom.get("as") == "geometry":
if geom.get("relative") == "1":
Expand All @@ -102,8 +103,8 @@ def get_geometry(cell: ET.Element) -> Rect | None:


def resolve_edge_label_position(
cell: ET.Element,
cells: dict[str, ET.Element],
cell: Element,
cells: dict[str, Element],
geom_cache: dict[str, Rect],
) -> Rect | None:
"""Resolve an edge label's absolute position by finding the midpoint
Expand Down Expand Up @@ -158,7 +159,7 @@ def resolve_edge_label_position(

def resolve_absolute(
cell_id: str,
cells: dict[str, ET.Element],
cells: dict[str, Element],
geom_cache: dict[str, Rect],
) -> Rect | None:
if cell_id in geom_cache:
Expand Down Expand Up @@ -199,7 +200,7 @@ def resolve_absolute(
return abs_rect


def is_on_diagram_badge(cell: ET.Element) -> bool:
def is_on_diagram_badge(cell: Element) -> bool:
"""On-diagram step badge: fillColor=#007CBD, numeric value, not in legend."""
style = get_style_dict(cell.get("style", ""))
fill = style.get("fillColor", "").upper()
Expand All @@ -219,7 +220,7 @@ def is_on_diagram_badge(cell: ET.Element) -> bool:
return bool(re.match(r"^\d{1,2}$", stripped))


def classify_cell(cell: ET.Element) -> str:
def classify_cell(cell: Element) -> str:
"""Classify a cell as 'badge', 'obstacle', or 'skip'."""
cell_id = cell.get("id", "")
if cell_id in ("0", "1"):
Expand Down Expand Up @@ -309,14 +310,14 @@ def compute_min_clearance(


def fix_badges(
tree: ET.ElementTree,
tree: ElementTree,
clearance: float = 10.0,
verbose: bool = False,
) -> int:
"""Fix badge overlaps in-place. Returns number of badges moved."""
root_elem = tree.getroot()

cells: dict[str, ET.Element] = {}
cells: dict[str, Element] = {}
for cell in root_elem.iter("mxCell"):
cid = cell.get("id")
if cid:
Expand Down
9 changes: 5 additions & 4 deletions plugins/deploy-on-aws/scripts/lib/post_process_drawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import os
import sys
import defusedxml.ElementTree as ET
from xml.etree.ElementTree import Element, ElementTree
from pathlib import Path

MAX_FILE_SIZE = 2 * 1024 * 1024 # 2 MB
Expand Down Expand Up @@ -55,7 +56,7 @@ def get_style_dict(style_str: str) -> dict[str, str]:
return result


def get_geometry(cell: ET.Element) -> dict[str, float] | None:
def get_geometry(cell: Element) -> dict[str, float] | None:
for geom in cell:
if geom.tag == "mxGeometry" and geom.get("as") == "geometry":
if geom.get("relative") == "1":
Expand All @@ -69,7 +70,7 @@ def get_geometry(cell: ET.Element) -> dict[str, float] | None:
return None


def set_geometry(cell: ET.Element, **kwargs: float) -> None:
def set_geometry(cell: Element, **kwargs: float) -> None:
for geom in cell:
if geom.tag == "mxGeometry" and geom.get("as") == "geometry":
for k, v in kwargs.items():
Expand All @@ -78,7 +79,7 @@ def set_geometry(cell: ET.Element, **kwargs: float) -> None:
return


def fix_placement(tree: ET.ElementTree, verbose: bool = False) -> int:
def fix_placement(tree: ElementTree, verbose: bool = False) -> int:
"""Move external actors outside the AWS Cloud boundary.

External actors must be:
Expand Down Expand Up @@ -218,7 +219,7 @@ def fix_placement(tree: ET.ElementTree, verbose: bool = False) -> int:
return moved


def fix_legend_size(tree: ET.ElementTree, verbose: bool = False) -> int:
def fix_legend_size(tree: ElementTree, verbose: bool = False) -> int:
"""Resize legend panel to match the diagram's main content height.

Finds the legend-outer group and the AWS Cloud / Region group,
Expand Down