def pdf_zip(<EOL>input1: str,<EOL>input2: str,<EOL>output: str,<EOL>delete: bool = False,<EOL>revert: bool = False,<EOL>):
if os.path.isfile(output):<EOL><INDENT>ans = input(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % output<EOL>).lower()<EOL>if ans not in ["<STR_LIT:y>", "<STR_LIT>"]:<EOL><INDENT>return<EOL><DEDENT><DEDENT>outputfile = open(output, "<STR_LIT:wb>")<EOL>try:<EOL><INDENT>f1, f2 = open(input1, "<STR_LIT:rb>"), open(input2, "<STR_LIT:rb>")<EOL>r1, r2 = PdfFileReader(f1), PdfFileReader(f2)<EOL>writer = PdfFileWriter()<EOL>pages1 = [page for page in r1.pages]<EOL>pages2 = [page for page in r2.pages]<EOL>if not revert:<EOL><INDENT>for p1, p2 in zip(pages1, pages2):<EOL><INDENT>writer.addPage(p1)<EOL>writer.addPage(p2)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for p1, p2 in zip(pages1, reversed(pages2)):<EOL><INDENT>writer.addPage(p1)<EOL>writer.addPage(p2)<EOL><DEDENT><DEDENT>writer.write(outputfile)<EOL>f1.close()<EOL>f2.close()<EOL><DEDENT>except FileNotFoundError as e:<EOL><INDENT>print(e.strerror + "<STR_LIT>" + e.filename)<EOL><DEDENT>finally:<EOL><INDENT>outputfile.close()<EOL><DEDENT>if delete:<EOL><INDENT>os.remove(input1)<EOL>os.remove(input2)<EOL><DEDENT>
Zip pages of input1 and input2 in one output file. Useful for putting
even and odd pages together in one document.
:param input1: first input file
:param input2: second input file
:param output: output file
:param delete: if true the input files will be deleted after zipping