-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_barcode.py
71 lines (58 loc) · 1.66 KB
/
check_barcode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python
import sys
import json
def jsonInputHandler(filename):
"""Take json file containing tasks which contain orders and return dictionaries
{
"tasks": [
{
"orders": [
{
"A32": 1,
"B31": 2,
"target": "C11"
},
{
"A41": 3,
"target": "C12"
}
]
}
]
}
Keyword arguments:
filename - name of json file
Returns:
returnList - nested list of separate orders
"""
returnList = []
with open(filename) as fh:
jsonDict = json.load(fh)
taskList = jsonDict['tasks']
for orderDict in taskList:
orderList = list(orderDict.values())[0]
for order in orderList:
rackList = list(order.keys())
rackList.remove('target')
returnList.append(rackList)
return returnList
def compareBarcode(checkList):
"""Take a list of order lists and iterate through to check if barcodes match orders. If not, beep on laptop
Keyword arguments:
checkList - nested list of separate orders
Returns:
None
"""
for order in checkList:
while order != []:
print(order)
barcode = input("Barcode: ")[4:]
if barcode not in order:
print("\a")
else:
order.remove(barcode)
def main(argv):
checkList = jsonInputHandler('pick_tasks.json')
compareBarcode(checkList)
if __name__ == "__main__":
main(sys.argv)