-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyAuditDecoder.py
96 lines (93 loc) · 3.69 KB
/
KeyAuditDecoder.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from openpyxl import Workbook
# Returns array of room numbers to be used for comparisons later.
def building_check(bldg):
if bldg == "VDSB":
result = [1001, 4014, 1, 14]
elif bldg == "VDSC":
result = [1015, 4028, 15, 28]
elif bldg == "VDSD":
result = [1029, 4046, 29, 46]
elif bldg == "VDSE":
result = [1047, 4064, 47, 64]
elif bldg == "VDSF":
result = [1065, 4073, 65, 73]
elif bldg == "VDSG":
result = [1074, 4091, 74, 91]
elif bldg == "VDSH":
result = [1092, 4105, 92, 105]
elif bldg == "VDSI":
result = [1106, 4123, 106, 123]
elif bldg == "VDSJ":
result = [1124, 7138, 124, 138]
elif bldg == "VDSK":
result = [1139, 7149, 139, 149]
elif bldg == "VAV":
result = [1201, 4222, 201, 238]
return result
# Create spreadsheet.
book = Workbook()
sheet = book.active
# Create header.
sheet['A1'] = "Room"
sheet['B1'] = "Keycode"
# Used for roomspaces.
alph = ["A", "B", "C", "D", "C1", "C2"]
building = input("What building?\n")
ranges = building_check(building)
room = ranges[0]
# For VAV.
keyCode = 1
unit = input("What is the unit type for room " + building + "-" + str(room) + "?\n")
# Continuously decode until specified.
while unit != "DONE":
# Changing buildings when specified.
if unit == "NEW":
building = input("What building?\n")
ranges = building_check(building)
room = ranges[0]
unit = input("What is the unit type for room " + building + "-" + str(room) + "?\n")
if unit != "N" and unit != "" and unit != "4" and unit != "3":
keyCode = int(input("What is the key code for room " + building + "-" + str(room) + "A?\n"))
#Checking what unit type and decoding key code appropriately.
if unit == "A" or unit == "E":
print(building + "-" + str(room) + " corresponds to key code " + str(keyCode))
sheet.append([building + "-" + str(room) + "A", keyCode])
elif unit == "B":
for letter in alph:
if letter == "C":
break
print(building + "-" + str(room) + letter + " corresponds to key code " + str(keyCode))
sheet.append([building + "-" + str(room) + letter, keyCode])
keyCode += 1
elif unit == "C":
for letter in alph:
if letter != "C" and letter != "D":
print(building + "-" + str(room) + letter + " corresponds to key code " + str(keyCode))
sheet.append([building + "-" + str(room) + letter, keyCode])
keyCode += 1
elif unit == "D" or unit == "4":
for letter in alph:
if letter == "C1":
break
print(building + "-" + str(room) + letter + " corresponds to key code " + str(keyCode))
sheet.append([building + "-" + str(room) + letter, keyCode])
keyCode += 1
# For VAV.
elif unit == "3":
for letter in alph:
if letter == "D":
break
print(building + "-" + str(room) + letter + " corresponds to key code " + str(keyCode))
sheet.append([building + "-" + str(room) + letter, keyCode])
keyCode += 1
room += 1
# Changing buildings when reaching the end of room numbers for the building.
if room > ranges[1]:
building = input("What building?\n")
ranges = building_check(building)
room = ranges[0]
# Incrementing the floor number when reaching the end of the building range, if the floor is still within the range.
elif int(str(room)[1:]) > ranges[3]:
room = room + 1000 - (ranges[3] - ranges[2] + 1)
unit = input("What is the unit type for room " + building + "-" + str(room) + "?\n")
book.save("Decoded.xlsx")