Skip to content

Commit

Permalink
switching to click for better path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfunley committed Nov 5, 2024
1 parent 926bca6 commit 8f30f20
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 46 deletions.
103 changes: 59 additions & 44 deletions keynote_export/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import itertools
import os
import shutil
from argparse import ArgumentParser
from contextlib import closing
from glob import glob
from typing import Optional

import appscript
import click
from jinja2 import Environment, FileSystemLoader
from reportlab.lib.colors import HexColor
from reportlab.lib.enums import TA_LEFT
Expand Down Expand Up @@ -154,54 +155,68 @@ def imgpath(s):
)


def main():
ap = ArgumentParser()
ap.add_argument(
"-k", "--keynote", help="Path to the keynote to convert", required=True
)
ap.add_argument(
"-o", "--outdir", help="Where to put the output.", required=True
)
ap.add_argument(
"-p", "--pagesize", help="The size of the pages.", default="1920x1080"
)
ap.add_argument(
"-f",
"--font-size",
help="Font size for notes",
type=int,
dest="font_size",
default=36,
)
ap.add_argument("-t", "--title", help="Title of the presentation")
ap.add_argument(
"-u",
"--bluesky-handle",
help="BlueSky handle for author",
dest="bsky_handle",
)
ap.add_argument(
"-sb",
"--skip-builds",
help="Skip build stages and just output one JPG per slide",
action="store_true",
dest="skip_builds",
)

args = ap.parse_args()
pagesize = tuple([int(s) for s in args.pagesize.split("x")])
@click.command()
@click.option(
"-k",
"--keynote",
type=click.Path(exists=True, file_okay=True, dir_okay=False),
help="Path to the keynote to convert",
required=True,
)
@click.option(
"-o",
"--outdir",
type=click.Path(file_okay=False, dir_okay=True),
help="Where to put the output.",
required=True,
)
@click.option(
"-p",
"--pagesize",
default="1920x1080",
help="The size of the pages.",
type=click.STRING,
)
@click.option(
"-f",
"--font-size",
type=click.INT,
help="Font size for notes",
default=36,
)
@click.option("-t", "--title", help="Title of the presentation", required=True)
@click.option(
"-u",
"--bluesky-handle",
help="BlueSky handle for author",
required=False,
type=click.STRING,
)
@click.option(
"--skip-builds", is_flag=True, help="Skip build stages", default=False
)
def main(
keynote: str,
outdir: str,
pagesize: str,
font_size: int,
title: str,
bluesky_handle: Optional[str],
skip_builds: bool,
):
pagesize = tuple([int(s) for s in pagesize.split("x")])
opts = Options(
args.outdir,
outdir,
pagesize,
args.font_size,
args.title,
args.bsky_handle,
args.skip_builds,
font_size,
title,
bluesky_handle,
skip_builds,
)

print("Processing", args.keynote)
print("Processing", keynote)
make_dirs(opts)
notes = export_keynote(args.keynote, opts)
notes = export_keynote(keynote, opts)
generate_pdf(opts, notes)
generate_html(opts, notes)

Expand Down
27 changes: 26 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keynote_export"
version = "0.1.4"
version = "0.1.5"
description = ""
authors = ["Dan McKinley <[email protected]>"]
repository = "https://github.com/mcfunley/better-keynote-export"
Expand Down Expand Up @@ -35,6 +35,7 @@ python = "^3.12"
jinja2 = "^3.1.4"
appscript = "^1.3.0"
reportlab = "^4.2.5"
click = "^8.1.7"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit 8f30f20

Please sign in to comment.