def split(args):
    files = args
    verbose = staplelib.OPTIONS.verbose

    if not files:
        raise CommandError("No input files specified.")

    inputs = []
    try:
        for f in files:
            inputs.append(iohelper.read_pdf(f))
    except Exception, e:
        raise CommandError(e)

    filecount = 0
    pagecount = 0
    for input in inputs:
        # zero-padded output file name
        (base, ext) = os.path.splitext(os.path.basename(files[filecount]))
        output_template = ''.join([
            base,
            '_',
            '%0',
            str(math.ceil(math.log10(input.getNumPages()))),
            'd',
            ext
        ])

        for pageno in range(input.getNumPages()):
            output = PdfFileWriter()
            output.addPage(input.getPage(pageno))

            outputname = output_template % (pageno + 1)
            if verbose:
                print outputname
            iohelper.write_pdf(output, staplelib.OPTIONS.destdir +
                               os.sep + outputname)
            pagecount += 1
        filecount += 1

    if verbose:
        print "\n{} page(s) in {} file(s) processed.".format(
            pagecount, filecount)
Burst an input file into one file per page.
dataset/ETHPy150Open hellerbarde/stapler/staplelib/commands.py/split