From 643b0e814606eb2e848f059c3a35c89f35635d67 Mon Sep 17 00:00:00 2001 From: zevav Date: Sat, 13 Jun 2020 17:55:09 +0200 Subject: [PATCH] added num columns option --- app/main.py | 3 +++ app/pdf.py | 12 ++++++++---- setup.py | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/main.py b/app/main.py index 79a901d..7837d7d 100755 --- a/app/main.py +++ b/app/main.py @@ -13,6 +13,7 @@ from app.pdf import make_pdf @click.option("--silent", default=False, is_flag=True) @click.option("--include-answers", default=True, is_flag=True) @click.option("--output-filepath") +@click.option("--num-columns", default=4) def main( bits: int, num_problems: int, @@ -20,6 +21,7 @@ def main( silent: bool = False, include_answers: bool = True, output_filepath: str = None, + num_columns: int = 4, ) -> None: validate_args(pdf, silent, output_filepath) @@ -32,6 +34,7 @@ def main( answers=answers, output_path=output_filepath or "problems.pdf", include_answers=include_answers, + num_columns=num_columns, ) if not silent: diff --git a/app/pdf.py b/app/pdf.py index e9a0ad0..18055d0 100644 --- a/app/pdf.py +++ b/app/pdf.py @@ -6,7 +6,11 @@ POSTSCRIPT_FILEPATH = "tempfile.ps" def make_pdf( - problems: str, answers: str, output_path: str, include_answers: bool + problems: str, + answers: str, + output_path: str, + include_answers: bool, + num_columns: int, ) -> None: if include_answers: pdf_jobs = (("problems", problems), ("answers", answers)) @@ -18,7 +22,7 @@ def make_pdf( output_path = make_answers_path(output_path) with tempfile.NamedTemporaryFile(mode="w") as txt_file: write_to_txtfile(txt_file, text) - make_postscript_file(txt_file) + make_postscript_file(txt_file, num_columns) make_pdf_file(output_path) os.unlink(POSTSCRIPT_FILEPATH) @@ -39,6 +43,6 @@ def make_pdf_file(output_path): subprocess.call(command, shell=True) -def make_postscript_file(txt_file): - command = f"enscript --columns=4 --no-header --output={POSTSCRIPT_FILEPATH} {txt_file.name}" +def make_postscript_file(txt_file, num_columns): + command = f"enscript --columns={num_columns} --no-header --output={POSTSCRIPT_FILEPATH} {txt_file.name}" subprocess.call(command, shell=True) diff --git a/setup.py b/setup.py index 46d8de8..4c5de60 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name="binary_quiz", author="Zev Averbach", author_email="zev@averba.ch", - version="0.1.1", + version="0.1.3", license="MIT", long_description_content_type="text/markdown", description=(