def embed_file(path: os.PathLike) -> IPython.display.HTML: """Embeds a file in the notebook as an html tag with a data-url.""" path = pathlib.Path(path) mime, unused_encoding = mimetypes.guess_type(str(path)) data = path.read_bytes() return embed_data(mime, data)
def _ensure_CRLF(src: os.PathLike, dst: Optional[os.PathLike] = None) -> Path: """Replace unix line endings with win. Return path to modified file.""" src = Path(src) dst = Path(dst or src) # overwrite src if dst is undefined dst.write_bytes(_RE_LF.sub(b"\r\n", src.read_bytes())) return dst