def pdf_rotate(<EOL>input: str,<EOL>counter_clockwise: bool = False,<EOL>pages: [str] = None,<EOL>output: str = None,<EOL>):
infile = open(input, "<STR_LIT:rb>")<EOL>reader = PdfFileReader(infile)<EOL>writer = PdfFileWriter()<EOL>if pages is None:<EOL><INDENT>source_pages = reader.pages<EOL><DEDENT>else:<EOL><INDENT>pages = parse_rangearg(pages, len(reader.pages))<EOL>source_pages = [reader.getPage(i) for i in pages]<EOL><DEDENT>for i, page in enumerate(source_pages):<EOL><INDENT>if pages is None or i in pages:<EOL><INDENT>if counter_clockwise:<EOL><INDENT>writer.addPage(page.rotateCounterClockwise(<NUM_LIT>))<EOL><DEDENT>else:<EOL><INDENT>writer.addPage(page.rotateClockwise(<NUM_LIT>))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>writer.addPage(page)<EOL><DEDENT><DEDENT>if output is None:<EOL><INDENT>outfile = NamedTemporaryFile(delete=False)<EOL><DEDENT>else:<EOL><INDENT>if not os.path.isfile(output) or overwrite_dlg(output):<EOL><INDENT>outfile = open(output, "<STR_LIT:wb>")<EOL><DEDENT>else:<EOL><INDENT>return<EOL><DEDENT><DEDENT>writer.write(outfile)<EOL>infile.close()<EOL>outfile.close()<EOL>if output is None:<EOL><INDENT>if overwrite_dlg(input):<EOL><INDENT>os.remove(input)<EOL>move(outfile.name, input)<EOL><DEDENT>else:<EOL><INDENT>os.remove(outfile.name)<EOL><DEDENT><DEDENT>
Rotate the given Pdf files clockwise or counter clockwise.
:param inputs: pdf files
:param counter_clockwise: rotate counter clockwise if true else clockwise
:param pages: list of page numbers to rotate, if None all pages will be
    rotated