示例#1
0
文件: embed.py 项目: 5l1v3r1/docs-4
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)
示例#2
0
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