<commit_before>"""
pi-scanner
Barcode scanner project for the Raspberry Pi.
"""

import sys, getopt
import json
import gspread
from gspread.exceptions import CellNotFound
from oauth2client.client import SignedJwtAssertionCredentials

def main(argv):
	oauthFile = ''
	try:
		opts, args = getopt.getopt(argv,"i:",["ifile="])
	except getopt.GetoptError:
		print 'pi-scanner.py -i <oauth file>'
		sys.exit(2)
			
	for opt, arg in opts:
		if opt in ("-i", "--ifile"):
			oauthFile = arg		
	
	print('Input file is [%s].' % oauthFile)
	
	json_key = json.load(open(oauthFile))
	scope = ['https://spreadsheets.google.com/feeds']
	
	credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope)
	
	gc = gspread.authorize(credentials)
	
	wks = gc.open("Test Sheet 1").sheet1
	
	print('Cell A1 is [%s].' % wks.acell('A1').value)
	print('Cell A2 is [%s].' % wks.acell('A2').value)
	print('Cell B1 is [%s].' % wks.acell('B1').value)
	print('Cell B2 is [%s].' % wks.acell('B2').value)
		
	while True:    # Read input forever
		barcode = raw_input("Enter the barcode: ")
		if barcode == "quit":
			break  # Exit the program

		print('Barcode is %s \n' % barcode)
		try:<commit_msg>Changed reading input to argparse.<commit_after>"""
pi-scanner
Barcode scanner project for the Raspberry Pi.
"""

import sys, argparse
import json
import gspread
from gspread.exceptions import CellNotFound
from oauth2client.client import SignedJwtAssertionCredentials

def main(argv):
	parser = argparse.ArgumentParser(description='pi-scanner - Barcode scanner project for the Raspberry Pi.', prefix_chars='-')
	parser.add_argument('-i', dest='oauthFile', action='store', required=True, help='OAuth file.')
	parser.add_argument('-sn', dest='sheetName', action='store', required=True, help='The name of the excel sheet.')
	
	args = parser.parse_args()
	
	if not args.oauthFile:
		parser.print_help()
		Sys.exit(2)
	if not args.sheetName:
		parser.print_help()
		Sys.exit(2)
	
	oauthFile = args.oauthFile
	sheetName = args.sheetName
	
	print('Input file is [%s].' % oauthFile)
	print('Sheet name is [%s].' % sheetName)
	
	json_key = json.load(open(oauthFile))
	scope = ['https://spreadsheets.google.com/feeds']
	
	credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope)
	
	gc = gspread.authorize(credentials)
	
	wks = gc.open("Test Sheet 1").sheet1
	
	print('Cell A1 is [%s].' % wks.acell('A1').value)
	print('Cell A2 is [%s].' % wks.acell('A2').value)
	print('Cell B1 is [%s].' % wks.acell('B1').value)
	print('Cell B2 is [%s].' % wks.acell('B2').value)
		
	while True:    # Read input forever
		barcode = raw_input("Enter the barcode: ")
		if barcode == "quit":
			break  # Exit the program

		print('Barcode is %s \n' % barcode)
		try:
{'fraction_non_alphanumeric': 0.1568627450980392, 'fraction_numerical': 0.008912655971479501, 'mean_word_length': 4.48046875, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '860788', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1009, 'n_words': 249}