def get_svg_string(svg):
    """Return the raw string of an SVG object with a ``tostring`` or ``to_str`` method."""
    if isinstance(svg, str):
        return svg
    if hasattr(svg, "tostring"):
        # svgwrite.drawing.Drawing.tostring()
        return svg.tostring()
    if hasattr(svg, "to_str"):
        # svgutils.transform.SVGFigure.to_str()
        return svg.to_str()
    raise TypeError(f"SVG cannot be converted to a raw string: {svg}")