Skip to content

Commit 26c0090

Browse files
committed
Require keywords for render function for all but first arg
This keeps us from committing to a particular order of arguments going forward.
1 parent ac4bfcd commit 26c0090

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

rmrl/render.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,17 @@
3333

3434
log = logging.getLogger(__name__)
3535

36-
def render(source, vector=True, prog_cb=lambda x: None):
36+
def render(source, *, progress_cb=lambda x: None):
3737
# Exports the self as a PDF document to disk
3838

39-
# prog_cb will be called with a progress percentage between 0 and
39+
# progress_cb will be called with a progress percentage between 0 and
4040
# 100. This percentage calculation is split 50% for the rendering
4141
# of the lines and 50% merging with the base PDF file. This callback
4242
# also provides an opportunity to abort the process. If the callback
4343
# raises an error, this function will take steps to abort gracefullly
4444
# and pass the error upwards.
4545

46+
vector=True # TODO: Different rendering styles
4647
source = sources.get_source(source)
4748

4849
# If this is using a base PDF, the percentage is calculated
@@ -78,15 +79,15 @@ def render(source, vector=True, prog_cb=lambda x: None):
7879
changed_pages.append(i)
7980
page.render_to_painter(pdf_canvas, vector)
8081
annotations.append(page.get_grouped_annotations())
81-
prog_cb((i + 1) / len(pages) * 50)
82+
progress_cb((i + 1) / len(pages) * 50)
8283
pdf_canvas.save()
8384
tmpfh.seek(0)
8485

8586
# This new PDF represents just the notebook. If there was a
8687
# parent PDF, merge it now.
8788
if uses_base_pdf and not changed_pages:
8889
# Since there is no stroke data, just return the PDF data
89-
prog_cb(100)
90+
progress_cb(100)
9091

9192
log.info('exported pdf')
9293
return source.open('{ID}.pdf', 'rb')
@@ -132,7 +133,7 @@ def render(source, vector=True, prog_cb=lambda x: None):
132133
if uses_base_pdf:
133134
merge_pages(basepage, rmpage, i in changed_pages)
134135

135-
prog_cb(((i + 1) / rmpdfr.numPages * 50) + 50)
136+
progress_cb(((i + 1) / rmpdfr.numPages * 50) + 50)
136137

137138
# Apply the OCG order. The basepdf may have already had OCGs
138139
# and so we must not overwrite them. NOTE: there are other

0 commit comments

Comments
 (0)