added num columns option

This commit is contained in:
2020-06-13 17:55:09 +02:00
parent 51bcf6f033
commit 643b0e8146
3 changed files with 12 additions and 5 deletions

View File

@@ -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:

View File

@@ -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)

View File

@@ -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=(