forked from pavpanchekha/keylogger.el
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtransform.py
More file actions
executable file
·40 lines (31 loc) · 1.09 KB
/
Copy pathtransform.py
File metadata and controls
executable file
·40 lines (31 loc) · 1.09 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
#!/usr/bin/env python3
import sys
import os
'''
Transforms two lists in `keys` into a format that may be easily read by other
scripts.
'''
for keylayout in ["qwerty", "mtgap2"]:
INFILE = sys.argv[1] if len(sys.argv) > 1 else \
os.path.expanduser("~/.emacs.d/mdickens/keylogger.el/keys-" + keylayout)
OUTFILE = sys.argv[2] if len(sys.argv) > 2 else "keys-" + \
keylayout + ".jsonp"
with open(INFILE) as f:
# First line blank
assert not f.readline().strip()
# Second line has an array
v = f.readline().strip()
assert v and v[0] == "[" and v[-1] == "]"
data = [[float(s)] for s in v[1:-1].split()]
# Third line blank
assert not f.readline().strip()
# Fourth line has another array
v = f.readline().strip()
assert v and v[0] == "[" and v[-1] == "]"
for i, s in enumerate(v[1:-1].split()):
data[i].append(int(s))
assert len(data) == 96 * 96
with open(OUTFILE, "w") as f:
f.write("load_data(")
f.write(str(data))
f.write(")")