added num columns option
This commit is contained in:
@@ -13,6 +13,7 @@ from app.pdf import make_pdf
|
|||||||
@click.option("--silent", default=False, is_flag=True)
|
@click.option("--silent", default=False, is_flag=True)
|
||||||
@click.option("--include-answers", default=True, is_flag=True)
|
@click.option("--include-answers", default=True, is_flag=True)
|
||||||
@click.option("--output-filepath")
|
@click.option("--output-filepath")
|
||||||
|
@click.option("--num-columns", default=4)
|
||||||
def main(
|
def main(
|
||||||
bits: int,
|
bits: int,
|
||||||
num_problems: int,
|
num_problems: int,
|
||||||
@@ -20,6 +21,7 @@ def main(
|
|||||||
silent: bool = False,
|
silent: bool = False,
|
||||||
include_answers: bool = True,
|
include_answers: bool = True,
|
||||||
output_filepath: str = None,
|
output_filepath: str = None,
|
||||||
|
num_columns: int = 4,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
validate_args(pdf, silent, output_filepath)
|
validate_args(pdf, silent, output_filepath)
|
||||||
@@ -32,6 +34,7 @@ def main(
|
|||||||
answers=answers,
|
answers=answers,
|
||||||
output_path=output_filepath or "problems.pdf",
|
output_path=output_filepath or "problems.pdf",
|
||||||
include_answers=include_answers,
|
include_answers=include_answers,
|
||||||
|
num_columns=num_columns,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not silent:
|
if not silent:
|
||||||
|
|||||||
12
app/pdf.py
12
app/pdf.py
@@ -6,7 +6,11 @@ POSTSCRIPT_FILEPATH = "tempfile.ps"
|
|||||||
|
|
||||||
|
|
||||||
def make_pdf(
|
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:
|
) -> None:
|
||||||
if include_answers:
|
if include_answers:
|
||||||
pdf_jobs = (("problems", problems), ("answers", answers))
|
pdf_jobs = (("problems", problems), ("answers", answers))
|
||||||
@@ -18,7 +22,7 @@ def make_pdf(
|
|||||||
output_path = make_answers_path(output_path)
|
output_path = make_answers_path(output_path)
|
||||||
with tempfile.NamedTemporaryFile(mode="w") as txt_file:
|
with tempfile.NamedTemporaryFile(mode="w") as txt_file:
|
||||||
write_to_txtfile(txt_file, text)
|
write_to_txtfile(txt_file, text)
|
||||||
make_postscript_file(txt_file)
|
make_postscript_file(txt_file, num_columns)
|
||||||
make_pdf_file(output_path)
|
make_pdf_file(output_path)
|
||||||
os.unlink(POSTSCRIPT_FILEPATH)
|
os.unlink(POSTSCRIPT_FILEPATH)
|
||||||
|
|
||||||
@@ -39,6 +43,6 @@ def make_pdf_file(output_path):
|
|||||||
subprocess.call(command, shell=True)
|
subprocess.call(command, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def make_postscript_file(txt_file):
|
def make_postscript_file(txt_file, num_columns):
|
||||||
command = f"enscript --columns=4 --no-header --output={POSTSCRIPT_FILEPATH} {txt_file.name}"
|
command = f"enscript --columns={num_columns} --no-header --output={POSTSCRIPT_FILEPATH} {txt_file.name}"
|
||||||
subprocess.call(command, shell=True)
|
subprocess.call(command, shell=True)
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -8,7 +8,7 @@ setup(
|
|||||||
name="binary_quiz",
|
name="binary_quiz",
|
||||||
author="Zev Averbach",
|
author="Zev Averbach",
|
||||||
author_email="zev@averba.ch",
|
author_email="zev@averba.ch",
|
||||||
version="0.1.1",
|
version="0.1.3",
|
||||||
license="MIT",
|
license="MIT",
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
description=(
|
description=(
|
||||||
|
|||||||
Reference in New Issue
Block a user