add line numbers, make it one column by default

This commit is contained in:
2020-06-14 10:35:00 +02:00
parent 53de04f697
commit c462ab0e3e
6 changed files with 24 additions and 20 deletions

10
TODO.md
View File

@@ -1,11 +1,13 @@
## TODO
- silent mode by default when doing PDF
- add nice spacing and typography for easy reading
- make
- pdf options
- problem numbers [true]
- number of columns [auto]
- include column labels
- print
- make it prettier
- different font, using nice fonts if they're available on someone's system
- better spacing
- [use different sized fonts for different parts](https://unix.stackexchange.com/a/500365)
- arithmetic
- addition
- subtraction
- mult? div?

View File

@@ -13,8 +13,8 @@ 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)
@click.option("--font-size", default=12)
@click.option("--num-columns", default=1)
@click.option("--font-size", default=26)
def main(
bits: int,
num_problems: int,
@@ -22,17 +22,14 @@ def main(
silent: bool = False,
include_answers: bool = True,
output_filepath: str = None,
num_columns: int = 4,
font_size: int = 12,
num_columns: int = 1,
font_size: int = 26,
) -> None:
validate_args(pdf, silent, output_filepath)
answers, problems = make_problems_and_answers(bits, num_problems)
if bits > 12:
num_columns = 3
if pdf:
silent = True
make_pdf(
@@ -65,8 +62,13 @@ def validate_args(pdf, silent, output_filepath):
def make_problems_and_answers(bits, num_problems):
problems = generate_problems(bits, num_problems)
answers = generate_answers(problems)
problems_string = "\n\n".join(problems)
problems_string = "\n\n".join(
[f"{index:2}) {p} =" for index, p in enumerate(problems, start=1)]
)
answers_string = "\n\n".join(
[f"{problem} | {answer} " for problem, answer in zip(problems, answers)]
[
f"{index:2}) {problem} = {answer}"
for index, (problem, answer) in enumerate(zip(problems, answers), start=1)
]
)
return answers_string, problems_string

View File

@@ -46,9 +46,9 @@ def make_pdf_file(output_path):
subprocess.call(command, shell=True)
def make_postscript_file(txt_file: str, num_columns: int, font_size: int):
def make_postscript_file(txt_file, num_columns: int, font_size: int):
command = (
f"enscript --columns={num_columns} --no-header --output={POSTSCRIPT_FILEPATH} "
f"-FCourier{font_size} {txt_file.name}"
f"enscript --columns={num_columns} --no-header --font=Courier{font_size} "
f"--output={POSTSCRIPT_FILEPATH} {txt_file.name}"
)
subprocess.call(command, shell=True)

BIN
problems-answers.pdf Normal file

Binary file not shown.

BIN
problems.pdf Normal file

Binary file not shown.

View File

@@ -8,7 +8,7 @@ setup(
name="binary_quiz",
author="Zev Averbach",
author_email="zev@averba.ch",
version="0.1.6",
version="0.1.8",
license="MIT",
long_description_content_type="text/markdown",
description=(