Skip to content

Commit

Permalink
Merge branch 'add_collate_option'
Browse files Browse the repository at this point in the history
This branch adds the --collate {on,off} argument to generate_pdf.py.
  • Loading branch information
philsc committed May 5, 2013
2 parents d4eb3e5 + 7f77dc0 commit b424c36
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 6 additions & 1 deletion generate_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()
17 changes: 12 additions & 5 deletions scantron.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,19 @@ def add_sheet(self, data, match=1, position=1):
self.draw_boolean(field.label)


def populate(self, data, matches=1):
for match in range(1, matches + 1):
def populate(self, data, matches=1, collate='on'):
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):
Expand Down

0 comments on commit b424c36

Please sign in to comment.