diff --git a/read_pdf.py b/read_pdf.py new file mode 100755 index 0000000..13f8216 --- /dev/null +++ b/read_pdf.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python2 + +import os +import sys +from argparse import ArgumentParser +from scantron import ScantronParser + +# Make this file easier to use by adding nice arguments +parser = ArgumentParser(description='Parse scanned scantron sheets.') +parser.add_argument( + 'data', + metavar='input_data', + help='File where the field data is stored. ' + + 'This must be a python script with an array called "data" ' + + 'of Field entries.') + +args = parser.parse_args() + +# If the file has a .py extension, we should still accept it +if args.data.endswith('.py'): + args.data = os.path.splitext(args.data)[0] + +# Import the file specified on the command line +try: + __import__(args.data) + data = sys.modules[args.data].data +except ImportError: + print('Failed to import %s.' % args.data) + quit(1) +except AttributeError: + print('Could not find data array.') + quit(1) + +# If everything went well, proceed to parse the filled scantron +st = ScantronParser() +st.scan(data, 'pages/page-1.jpg') diff --git a/scantron.py b/scantron.py index e97d8ac..5b39cc9 100755 --- a/scantron.py +++ b/scantron.py @@ -6,6 +6,15 @@ from qrcode import * +class ScantronParser: + def __init__(self): + pass + + + def scan(self, data, path): + pass + + class Scantron: def __init__(self, filename, spacing=0.3*inch): self._fontSize = 0.15*inch