Skip to content

Commit

Permalink
Adding a basic read_pdf.py script.
Browse files Browse the repository at this point in the history
This is intended to grow into the counterpart of generate_pdf.py.
  • Loading branch information
philsc committed May 5, 2013
1 parent b424c36 commit 7cb1f50
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
36 changes: 36 additions & 0 deletions read_pdf.py
Original file line number Diff line number Diff line change
@@ -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')
9 changes: 9 additions & 0 deletions scantron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7cb1f50

Please sign in to comment.