add line numbers, make it one column by default
This commit is contained in:
16
TODO.md
16
TODO.md
@@ -1,13 +1,15 @@
|
|||||||
## TODO
|
## TODO
|
||||||
- silent mode by default when doing PDF
|
- make
|
||||||
- add nice spacing and typography for easy reading
|
|
||||||
- pdf options
|
- pdf options
|
||||||
- problem numbers [true]
|
|
||||||
- number of columns [auto]
|
|
||||||
- include column labels
|
- include column labels
|
||||||
- print
|
- print
|
||||||
- addition
|
- make it prettier
|
||||||
- subtraction
|
- different font, using nice fonts if they're available on someone's system
|
||||||
- mult? div?
|
- better spacing
|
||||||
|
- [use different sized fonts for different parts](https://unix.stackexchange.com/a/500365)
|
||||||
|
- arithmetic
|
||||||
|
- addition
|
||||||
|
- subtraction
|
||||||
|
- mult? div?
|
||||||
- hex?
|
- hex?
|
||||||
|
|
||||||
|
|||||||
20
app/main.py
20
app/main.py
@@ -13,8 +13,8 @@ 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)
|
@click.option("--num-columns", default=1)
|
||||||
@click.option("--font-size", default=12)
|
@click.option("--font-size", default=26)
|
||||||
def main(
|
def main(
|
||||||
bits: int,
|
bits: int,
|
||||||
num_problems: int,
|
num_problems: int,
|
||||||
@@ -22,17 +22,14 @@ 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,
|
num_columns: int = 1,
|
||||||
font_size: int = 12,
|
font_size: int = 26,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
||||||
validate_args(pdf, silent, output_filepath)
|
validate_args(pdf, silent, output_filepath)
|
||||||
|
|
||||||
answers, problems = make_problems_and_answers(bits, num_problems)
|
answers, problems = make_problems_and_answers(bits, num_problems)
|
||||||
|
|
||||||
if bits > 12:
|
|
||||||
num_columns = 3
|
|
||||||
|
|
||||||
if pdf:
|
if pdf:
|
||||||
silent = True
|
silent = True
|
||||||
make_pdf(
|
make_pdf(
|
||||||
@@ -65,8 +62,13 @@ def validate_args(pdf, silent, output_filepath):
|
|||||||
def make_problems_and_answers(bits, num_problems):
|
def make_problems_and_answers(bits, num_problems):
|
||||||
problems = generate_problems(bits, num_problems)
|
problems = generate_problems(bits, num_problems)
|
||||||
answers = generate_answers(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(
|
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
|
return answers_string, problems_string
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ def make_pdf_file(output_path):
|
|||||||
subprocess.call(command, shell=True)
|
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 = (
|
command = (
|
||||||
f"enscript --columns={num_columns} --no-header --output={POSTSCRIPT_FILEPATH} "
|
f"enscript --columns={num_columns} --no-header --font=Courier{font_size} "
|
||||||
f"-FCourier{font_size} {txt_file.name}"
|
f"--output={POSTSCRIPT_FILEPATH} {txt_file.name}"
|
||||||
)
|
)
|
||||||
subprocess.call(command, shell=True)
|
subprocess.call(command, shell=True)
|
||||||
|
|||||||
BIN
problems-answers.pdf
Normal file
BIN
problems-answers.pdf
Normal file
Binary file not shown.
BIN
problems.pdf
Normal file
BIN
problems.pdf
Normal file
Binary file not shown.
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.6",
|
version="0.1.8",
|
||||||
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