"""Serialize a Show to a QLC+ 4.12 workspace.""" from __future__ import annotations from .model import Show, Universe, fixture_xml, group_xml, universe_xml def render_show(show: Show) -> str: universes = list(show.universes) or [Universe(i, f"Universe {i + 1}") for i in range(4)] universes.sort(key=lambda uni: uni.id) width, height = show.size() engine = [" "] engine.extend(universe_xml(uni) for uni in universes) engine.append(" ") engine.extend(fixture_xml(fx) for fx in show.fixtures) engine.extend(group_xml(group) for group in show.groups) engine.extend(fn.render() for fn in show.functions) widgets = show.vc.render(" ") return ( '\n' "\n" '\n' " \n" " Q Light Controller Plus\n" f" {show.version}\n" f" {_author(show.author)}\n" " \n" " \n" + "\n".join(engine) + "\n \n" " \n" + widgets + "\n \n" f' \n' ' \n' " \n" " \n" " \n" " \n" " \n" "\n" ) def _author(name: str) -> str: from .xmlutil import text return text(name)