From 4905c349f6bbdca0f765a9894d28c55d838ed3c7 Mon Sep 17 00:00:00 2001 From: Philipp Schrader Date: Sun, 5 May 2013 12:02:02 -0700 Subject: [PATCH 1/2] Adding collate option to the generate_pdf.py script. --- generate_pdf.py | 7 ++++++- scantron.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/generate_pdf.py b/generate_pdf.py index 2edd3e2..cd4288f 100755 --- a/generate_pdf.py +++ b/generate_pdf.py @@ -23,6 +23,11 @@ help='File where the field data is stored. ' + 'This must be a python script with an array called "data" ' + 'of Field entries.') +parser.add_argument( + '--collate', + choices=['on', 'off'], + default='on', + help='Turns collatating on or off. Default is on.') args = parser.parse_args() @@ -44,5 +49,5 @@ # If everything went well, proceed to generate the PDF st = Scantron(args.output, spacing=0.3*inch) st.set_box_sizes(box_size=0.2*inch, box_spacing=0.3*inch) -st.populate(data, matches=args.num_matches) +st.populate(data, matches=args.num_matches, collate=args.collate) st.save() diff --git a/scantron.py b/scantron.py index ecbed28..6155875 100755 --- a/scantron.py +++ b/scantron.py @@ -140,7 +140,7 @@ def add_sheet(self, data, match=1, position=1): self.draw_boolean(field.label) - def populate(self, data, matches=1): + def populate(self, data, matches=1, collate='on'): for match in range(1, matches + 1): for position in range(1, 7): self.add_sheet(data, match, position) From 7f77dc09065a06f52e3eea4b2a276282ecd02f0d Mon Sep 17 00:00:00 2001 From: Philipp Schrader Date: Sun, 5 May 2013 12:10:50 -0700 Subject: [PATCH 2/2] The scantron class will now honour the collate option. --- scantron.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scantron.py b/scantron.py index 6155875..e97d8ac 100755 --- a/scantron.py +++ b/scantron.py @@ -141,11 +141,18 @@ def add_sheet(self, data, match=1, position=1): def populate(self, data, matches=1, collate='on'): - for match in range(1, matches + 1): + if collate == 'on': + for match in range(1, matches + 1): + for position in range(1, 7): + self.add_sheet(data, match, position) + self._canvas.showPage() + self._reset_values() + else: for position in range(1, 7): - self.add_sheet(data, match, position) - self._canvas.showPage() - self._reset_values() + for match in range(1, matches + 1): + self.add_sheet(data, match, position) + self._canvas.showPage() + self._reset_values() def save(self):