fix: rack elevations missing in all export formats
RackElevationSVG falls back to RACK_ELEVATION_DEFAULT_* config parameters, which raise AttributeError on the target NetBox version. Pass the dimensions explicitly instead. Add a Pillow-based PNG rack renderer (role colors, unit legend, full-depth devices shown dimmed from the other side). It is used for Word when cairosvg is unavailable and replaces a failed SVG in all formats. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -53,11 +53,16 @@ def KV(pairs, skip_empty=True):
|
||||
|
||||
|
||||
def IMAGES(images):
|
||||
"""images: Liste von (svg_string, caption)."""
|
||||
"""images: Liste von (svg_string oder None, caption, png_bytes_oder_None)."""
|
||||
out = []
|
||||
for svg, caption in images:
|
||||
data = base64.b64encode(svg.encode("utf-8")).decode("ascii")
|
||||
out.append({"svg": svg, "caption": caption, "data_uri": f"data:image/svg+xml;base64,{data}"})
|
||||
for svg, caption, png in images:
|
||||
if svg:
|
||||
data_uri = "data:image/svg+xml;base64," + base64.b64encode(svg.encode("utf-8")).decode("ascii")
|
||||
elif png:
|
||||
data_uri = "data:image/png;base64," + base64.b64encode(png).decode("ascii")
|
||||
else:
|
||||
continue
|
||||
out.append({"svg": svg, "png": png, "caption": caption, "data_uri": data_uri})
|
||||
return Block("images", images=out)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user