This repository was archived by the owner on Jun 15, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathloadCode.py
More file actions
Latest commit
58 lines (44 loc) · 1.95 KB
/
Copy pathloadCode.py
File metadata and controls
58 lines (44 loc) · 1.95 KB
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
importre
fromencoderimportdecode_string
defloadFromInput(inp):
ifre.search(r"V1;\d+;\d+;(\d\.\d,)*(\d\.\d)?;([0-8]\.[0-3]\.\d+\.\d+,)*([0-8]\.[0-3]\.\d+\.\d+)?;[\w\d]*;", inp):
inp=inp.split(";")
returninp
elifre.search(r"V3;([\da-zA-Z!$%&+-.=?^{}\(\)]+;){2}[\da-zA-Z!$%&+-.=?^{}\(\)]*;[\w\s\-\.]*;", inp):
inp=inp.split(";")
level_cells=""
data_index=0# iterate through data optimally without re-slicing it every step
data=inp[3]
whiledata_index<len(data):
ifdata[data_index] =="("ordata[data_index] ==")":
ifdata[data_index] ==")":
offset=data[data_index+1]
distance=data[data_index+2]
data_index+=3
else:
offset=""
data_index+=1
whiledata[data_index] !="("anddata[data_index] !=")":
offset+=data[data_index]
data_index+=1
ifdata[data_index] ==")":
distance=data[data_index+1]
data_index+=2
else:
distance=""
data_index+=1
whiledata[data_index] !=")":
distance+=data[data_index]
data_index+=1
data_index+=1
fordinrange(decode_string(distance)):
level_cells+=level_cells[-decode_string(offset) -1]
else:
level_cells+=data[data_index]
data_index+=1
inp[3] =level_cells
returninp
elifinp.startswith("V2"):
return"V2"
else:
returnNone