12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #!/usr/bin/env python3
- import sys
- opening = False
- print("std::string lines[] = {")
- def printer(line):
- global opening
- if opening:
- if "[Pause]" in line:
- opening = False
- else:
- return
- out = repr(line)
- out.replace(r"\\\\", r"\\")
- out = out[1:-1]
- # print("[", repr(out), "]")
- if out.startswith("^\\r#"):
- return
- print('"', out, '",', sep="")
- if "Trade Wars 2002 Win32 module now" in line:
- opening = True
- filename = sys.argv[1]
- with open(filename) as fp:
- for line in fp:
- if " SL: " in line:
- _, part = line.strip().split(" SL: ")
- part = part[1:-1]
- # print(repr(part))
- printer(part)
- if " SP: " in line:
- _, part = line.strip().split(" SP: ")
- part = part[1:-1]
- # print("^", repr(part))
- printer("^" + part)
- if " CI: " in line:
- _, part = line.strip().split(" CI: ")
- part = part[1:-1]
- # print("!", repr(part))
- printer("!" + part)
- print("};")
|