from typing import TextIO
from io import StringIO
import base64


def svg_uri_embed(file_like: TextIO) -> StringIO:
    """Takes an SVG file in a TextIO and returns a StringIO with that SVG embedded in a data uri that can be put in an <img href="...">"""
    mime_type = "data:image/svg+xml;base64,"
    uri = StringIO(mime_type)
    uri.seek(0, 2)  # Move to end of "file"
    file_like.seek(0, 0)  # Move to beginning of "file"
    uri.write(
        base64.b64encode(
            file_like.read().encode("utf8")
        ).decode()  # Don't want bytes, want strings
    )
    uri.seek(0, 0)
    return uri