diff --git a/scripts/gen_rack.py b/scripts/gen_rack.py index 9996e8e..a43a17b 100644 --- a/scripts/gen_rack.py +++ b/scripts/gen_rack.py @@ -384,6 +384,25 @@ def render_svg(rack: str, items: list[dict]) -> str: if face in ("rear", "both"): draw_device(fm, rear_x) + def draw_rail(fm: dict, x: int) -> None: + color = KIND_COLORS.get(fm.get("kind", ""), DEFAULT_COLOR) + name = fm.get("hostname", "?") + cx = x + RAIL_W // 2 + cy = top + body_h // 2 + p.append( + f'' + ) + p.append( + f'{_esc(name)}' + ) + + for idx, fm in enumerate(left_items): + draw_rail(fm, PAD + idx * RAIL_W) + for idx, fm in enumerate(right_items): + draw_rail(fm, rear_x + COL_W + idx * RAIL_W) + SHELF_STRIP_H = 6 shelves = [i for i in items if i.get("kind") == "shelf"] mounted = [i for i in items if "mounted_on" in i] @@ -431,25 +450,6 @@ def render_svg(rack: str, items: list[dict]) -> str: for fm in sorted(shelves, key=lambda s: s.get("hostname", "")): draw_shelf(fm) - def draw_rail(fm: dict, x: int) -> None: - color = KIND_COLORS.get(fm.get("kind", ""), DEFAULT_COLOR) - name = fm.get("hostname", "?") - cx = x + RAIL_W // 2 - cy = top + body_h // 2 - p.append( - f'' - ) - p.append( - f'{_esc(name)}' - ) - - for idx, fm in enumerate(left_items): - draw_rail(fm, PAD + idx * RAIL_W) - for idx, fm in enumerate(right_items): - draw_rail(fm, rear_x + COL_W + idx * RAIL_W) - p.append("") return "\n".join(p) + "\n"