Add compiler and decompiler for .tm files

master
Micke Nordin 6 years ago
parent 884ad8121f
commit b9454659a3

@ -0,0 +1,22 @@
1:0,1,11,0,0,0
11:0,1,12,0,0,0
12:0,1,13,0,0,0
13:0,1,14,0,0,0
14:1,0,15,0,0,0
15:0,0,140,0,0,0
21:1,0,22,0,0,0
22:1,1,210,1,1,210
30:1,1,31,0,0,0
31:1,1,32,0,0,0,
32:1,1,33,0,0,0,
33:1,1,34,0,0,0,
34:1,1,35,0,0,0,
35:1,1,36,0,0,0,
36:1,1,37,0,0,0,
37:1,1,38,0,0,0
38:1,1,0,0,0,0
140:0,0,141,1,0,141
141:0,0,142,1,0,142
142:0,0,21,0,0,21
210:0,1,211,1,1,211
211:0,1,30,1,1,30

@ -4,4 +4,3 @@
0
0
0

@ -4,4 +4,3 @@
0
0
0

@ -4,4 +4,3 @@
0
0
0

@ -4,4 +4,3 @@
0
0
0

@ -4,4 +4,3 @@
0
0
0

@ -4,4 +4,3 @@
0
0
0

@ -0,0 +1,31 @@
#!/usr/bin/python3
import sys
import os
filename = sys.argv[1]
dirname = sys.argv[2]
os.mkdir(dirname)
# print("Card number: " + cardnumber + ", write zero: " + write_zero + ", move zero: " + move_zero + ", next zero: " + next_zero + ", write one: " + write_one + ", move one: " + move_one + ", next one: " + next_one )
with open(filename, 'r') as ip:
for line in ip:
arr1 = line.split(':')
arr2 = arr1[1].split(',')
cardnumber = arr1[0]
write_zero = arr2[0]
move_zero = arr2[1]
next_zero = arr2[2]
write_one = arr2[3]
move_one = arr2[4]
next_one = arr2[5]
with open(dirname + "/" + cardnumber, 'a') as op:
op.write(write_zero + '\n')
op.write(move_zero + '\n')
op.write(next_zero + '\n')
op.write(write_one + '\n')
op.write(move_one + '\n')
op.write(next_one + '\n')

@ -0,0 +1,22 @@
#!/usr/bin/python3
import sys
import os
filename = sys.argv[1]
dirname = sys.argv[2]
temp = []
for i in os.listdir(dirname):
temp.append(int(i))
cards = sorted(temp)
with open(filename, 'a') as op:
for i in cards:
card = str(i)
op.write(card + ":")
with open(dirname + "/" + card, 'r') as ip:
payload = ""
for line in ip:
payload = payload + line[:-1] + ','
payload = payload[:-1]
op.write(payload + '\n')
Loading…
Cancel
Save