saturn_notebook/__main__.py
def image(infn: "input notebook", i: "image index", out: "output PNG filename"):
    """Extract an image from the notebook."""
    if i is not None and not out:
        console.print("Must specify output filename, if image is specified")
        return

    with open(infn) as f:
        cells = c.parse(f, show_only = True)

    count = 0
    for cell in cells:
        if type(cell) is not c.OutputCell: continue

        for x in cell.composite_:
            if type(x) is io.StringIO: continue

            if i is None:
                print(f"{count}:")
                show_png(x)
            elif i == count:
                with open(out, 'wb') as f:
                    f.write(x)

            count += 1
Extract an image from the notebook.
Extract an image from the notebook.
Extract an image from the notebook .
def image(infn: "input notebook", i: "image index", out: "output PNG filename"):
    if i is not None and not out:
        console.print("Must specify output filename, if image is specified")
        return
    with open(infn) as f:
        cells = c.parse(f, show_only = True)
    count = 0
    for cell in cells:
        if type(cell) is not c.OutputCell: continue
        for x in cell.composite_:
            if type(x) is io.StringIO: continue
            if i is None:
                print(f"{count}:")
                show_png(x)
            elif i == count:
                with open(out, 'wb') as f:
                    f.write(x)
            count += 1
def image ( infn : "input notebook" , i : "image index" , out : "output PNG filename" ) : if i is not None and not out : console . print ( "Must specify output filename, if image is specified" ) return with open ( infn ) as f : cells = c . parse ( f , show_only = True ) count = 0 for cell in cells : if type ( cell ) is not c . OutputCell : continue for x in cell . composite_ : if type ( x ) is io . StringIO : continue if i is None : print ( f"{count}:" ) show_png ( x ) elif i == count : with open ( out , 'wb' ) as f : f . write ( x ) count += 1
Extract an image from the notebook.
Extract an image from the notebook .
"""Extract an image from the notebook."""
infn
"input notebook"
i
"image index"
out
"output PNG filename"