Skip to content

Instantly share code, notes, and snippets.

@wmw
Created July 19, 2019 05:03
Show Gist options
  • Save wmw/a947cf9e471da4846650f1b8d80008a6 to your computer and use it in GitHub Desktop.
Save wmw/a947cf9e471da4846650f1b8d80008a6 to your computer and use it in GitHub Desktop.
import sys
import getopt
import re
class Field:
def __init__(self, key, desc, typeinfo):
self.key = key
self.desc = desc
self.typeinfo = typeinfo
class Action:
Fields = []
@classmethod
def InitFields(cls, raw_key, raw_desc, raw_typeinfo):
key = raw_key.split(",")
desc = raw_desc.split(",")
typeinfo = raw_typeinfo.split(",")
for k,d,t in zip(key, desc, typeinfo):
field = Field(k, d, t)
cls.Fields.append(field)
def __init__(self, raw_data):
for f,v in zip(Action.Fields, raw_data.split(",")):
setattr(self, f.key, v)
def main(logfile, actionfile):
actions = {}
with open(actionfile, "r", encoding="utf-8-sig") as af:
raw_key = af.readline().strip()
raw_desc = af.readline().strip()
raw_typeinfo = af.readline().strip()
Action.InitFields(raw_key, raw_desc, raw_typeinfo)
while True:
data = af.readline()
if data:
action = Action(data.strip())
k = getattr(action, "key")
actions[k] = action
else:
break
with open(logfile, "r") as lf:
while True:
data = lf.readline()
if data:
m = re.search(r"(\"Unknown_([A-Za-z0-9]*)\")", data)
if m:
id = str(int(m.group(2), 16))
a = actions[id]
pretty_name = getattr(a, "0")
if pretty_name != "\"\"":
data = data.replace(m.group(1), pretty_name)
print(data.strip())
else:
break
if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "l:a:")
except getopt.GetoptError:
print("resolve_names.py -l <logfile> -a <actionfile>")
sys.exit(2)
for opt, arg in opts:
if opt == "-l":
logfile = arg
elif opt == "-a":
actionfile = arg
main(logfile, actionfile)
@wmw
Copy link
Author

wmw commented Jul 19, 2019

Example output from an Eden Prime timeline

PS C:\dev\cactbot\util> cd 'c:\dev\cactbot\util'; ${env:PYTHONIOENCODING}='UTF-8'; ${env:PYTHONUNBUFFERED}='1'; & 'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe' 'c:\Users\bill.BILL-W10.vscode\extensions\ms-python.python-2019.6.24221\pythonFiles\ptvsd_launcher.py' '--default' '--client' '--host' 'localhost' '--port' '50172' 'c:\dev\cactbot\util\resolve_names.py' '-a' 'Action.csv' '-l' 'eden_prime.txt'

11.6 "Spear of Paradise" sync /:Eden Prime:3DA1:/
12.9 "Heavensunder" sync /:Eden Prime:3DA2:/
21.6 "Eden's Gravity" sync /:Eden Prime:3D94:/
33.0 "Vice and Virtue" sync /:Eden Prime:44E5:/
33.0 "Vice of Apathy" sync /:Eden Prime:44E8:/
39.3 "Eden's Flare" sync /:Eden Prime:3D97:/
54.7 "Vice and Virtue" sync /:Eden Prime:44E4:/
55.4 "Vice of Vanity" sync /:Eden Prime:44E7:/
65.0 "Spear of Paradise" sync /:Eden Prime:3DA1:/
66.3 "Heavensunder" sync /:Eden Prime:3DA2:/
71.0 "Unknown_4683" sync /:Eden Prime:4683:/
84.1 "Pure Light" sync /:Eden Prime:3DA3:/
89.8 "Unknown_4683" sync /:Eden Prime:4683:/
98.7 "Delta Attack" sync /:Eden Prime:44EA:/
99.2 "Eden's Thunder III" sync /:Eden Prime:44ED:/
99.2 "Eden's Blizzard III" sync /:Eden Prime:44EC:/
99.2 "Eden's Fire III" sync /:Eden Prime:44EB:/
105.1 "Unknown_4683" sync /:Eden Prime:4683:/
111.7 "Dimensional Shift" sync /:Eden Prime:3D9C:/
120.1 "Pure Beam" sync /:Eden Prime:3D9D:/
125.5 "Pure Beam" sync /:Eden Prime:3D9E:/
125.5 "Paradise Lost" sync /:Eden Prime:3D9F:/
127.0 "Pure Beam" sync /:Eden Prime:3D9E:/
127.9 "Unknown_4683" sync /:Eden Prime:4683:/
128.6 "Paradise Lost" sync /:Eden Prime:3DA0:/
130.6 "Pure Beam" sync /:Eden Prime:3D9E:/
132.1 "Pure Beam" sync /:Eden Prime:3D9E:/
132.6 "Paradise Lost" sync /:Eden Prime:3DA0:/
135.6 "Pure Beam" sync /:Eden Prime:3D9E:/
136.6 "Paradise Lost" sync /:Eden Prime:3DA0:/
137.1 "Pure Beam" sync /:Eden Prime:3D9E:/
141.0 "Pure Light" sync /:Eden Prime:3DA3:/
143.7 "Unknown_4683" sync /:Eden Prime:4683:/
150.3 "Dimensional Shift" sync /:Eden Prime:3D9C:/
162.7 "Fragor Maximus" sync /:Eden Prime:3DA4:/
178.7 "Paradisal Dive" sync /:Guardian of Paradise:3DA9:/
189.7 "Mana Slice" sync /:Guardian of Paradise:3DA6:/
198.8 "Mana Burst" sync /:Guardian of Paradise:3DA7:/
204.9 "Mana Slice" sync /:Guardian of Paradise:3DA6:/
214.1 "Mana Burst" sync /:Guardian of Paradise:3DA7:/
223.3 "Primeval Stasis" sync /:Eden:3E3A:/
266.8 "Eternal Breath" sync /:Eden Prime:3DA5:/
282.8 "Vice and Virtue" sync /:Eden Prime:44E4:/
283.5 "Vice of Vanity" sync /:Eden Prime:44E7:/
293.1 "Spear of Paradise" sync /:Eden Prime:3DA1:/
294.4 "Heavensunder" sync /:Eden Prime:3DA2:/
299.1 "Unknown_4683" sync /:Eden Prime:4683:/
312.2 "Pure Light" sync /:Eden Prime:3DA3:/
318.0 "Unknown_4683" sync /:Eden Prime:4683:/
327.3 "Delta Attack" sync /:Eden Prime:44EA:/
327.8 "Eden's Thunder III" sync /:Eden Prime:44ED:/
327.8 "Eden's Blizzard III" sync /:Eden Prime:44EC:/
327.8 "Eden's Fire III" sync /:Eden Prime:44EB:/
327.8 "Eden's Fire III" sync /:Eden Prime:44EB:/
333.9 "Unknown_4683" sync /:Eden Prime:4683:/
340.4 "Dimensional Shift" sync /:Eden Prime:3D9C:/
348.9 "Pure Beam" sync /:Eden Prime:3D9D:/
354.3 "Paradise Lost" sync /:Eden Prime:3D9F:/
354.3 "Pure Beam" sync /:Eden Prime:3D9E:/
355.9 "Pure Beam" sync /:Eden Prime:3D9E:/
356.7 "Unknown_4683" sync /:Eden Prime:4683:/
357.3 "Paradise Lost" sync /:Eden Prime:3DA0:/
359.3 "Pure Beam" sync /:Eden Prime:3D9E:/
361.0 "Pure Beam" sync /:Eden Prime:3D9E:/
361.5 "Paradise Lost" sync /:Eden Prime:3DA0:/
364.4 "Pure Beam" sync /:Eden Prime:3D9E:/
365.5 "Paradise Lost" sync /:Eden Prime:3DA0:/
366.1 "Pure Beam" sync /:Eden Prime:3D9E:/
369.9 "Pure Light" sync /:Eden Prime:3DA3:/
372.7 "Unknown_4683" sync /:Eden Prime:4683:/
379.3 "Dimensional Shift" sync /:Eden Prime:3D9C:/
391.7 "Vice and Virtue" sync /:Eden Prime:44E5:/
391.7 "Vice of Apathy" sync /:Eden Prime:44E8:/
396.1 "Sunder Pressure" sync /:Eden Prime:44FF:/
398.0 "Eden's Flare" sync /:Eden Prime:3D97:/
409.4 "Eden's Gravity" sync /:Eden Prime:3D94:/
422.8 "Vice and Virtue" sync /:Eden Prime:44E4:/
423.5 "Vice of Vanity" sync /:Eden Prime:44E7:/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment