-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlm.py
More file actions
25 lines (23 loc) · 672 Bytes
/
lm.py
File metadata and controls
25 lines (23 loc) · 672 Bytes
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
#!/usr/bin/env python3
# simple parse tool to generate .html from .lm file
import sys
import parse
def main():
if len(sys.argv) == 1:
fn = input("file: ")
else:
fn = sys.argv[1]
with open(fn + ".lm", "r") as f:
f = f.read()
f = "".join(["(html", f, ")"])
lm = parse.eval_input(f)
if len(sys.argv) == 1:
print(lm)
wri = input("Write file?")
if wri not in ["0", "n"]:
with open(fn + ".html", "w") as nf:
nf.write(lm)
else:
with open(fn + ".html", "w") as nf:
nf.write(lm)
main()